1 public class hello 2 { 3 public static void main(String[] args) 4 { 5 //变量可随时进行赋值 6 int a=1; 7 a=2; 8 System.out.println(a); 9 10 //常量只能被赋值一次 11 final int B=1;//在数据类型前加final变为常量,一般常量都使用大写表示 12 System.out.println(B); 13 } 14 }