区分表述
一般将1,2,3,'a','b',true,false,''helloWorld''等称为字符常量
使用final修饰的PI为符号常量。
变量和常量起名规范
*起名不能瞎起,要一看就明白什么意思
*类成员变量:开头字母小写或驼峰原则:monthSalary
*局部变量:开头字母小写或驼峰原则
*常量:大写字母和下划线:MAX_VALUE
*类名:开始字母大写或驼峰原则:Man,GoodMan
*方法名:开头字母大写或驼峰原则:run(),runRun()
public class TestConstant{
public static vois main(String[] args){
final double PI =3.14;
final int MAX_SPEED = 120;//常量命名;全部用大写字母,单词之间要用下划线隔开
int r =4;
double area = PI*r*r;
double circle = 2*PI*r;
System.oub.println("面积是:"+area);
System.out.println("周长是:"+cirxle);
}
}