/**
- 用来测试注释的用法(包含:多行注释、单行注释、文档注释)
- @author 老窦
*/
public class TestComment {
/**
* 这是程序入口
* @param args 参数
*/
public static void main(String[] args/*我是多行注释!*/){
System.out.println("测试注释 "); //这是打印语句...
}
/*
我是多行注释!
我是多行注释!
*/
}
/**
- 测试常量
- @author 老窦
*/
public class TestConstant {
public static void main(String[] args) {
int age = 18;
final String NAME = "douqiushi"; //尽量用大写
final double PI = 3.14;
//PI = 3.15;//编译错误,不能再被赋值!
double r = 4;
double area = PI*r*r;
double circle = 2*PI*r;
System.out.println("area = " + area);
System.out.println("circle =" + circle);
}
}
/**
- 测试标识符的用法
- @author 老窦
*/
public class TestIdentifer {
public static void main(String[] args) {
int a123 = 1;
//int 123abc = 2; //数字不能开头
int $a = 3;
int _abc=4;
//int #abc = 5;
int 年龄 = 18; //可以使用汉字,一般不建议用
//int class = 2; //关键字不能作为标识符
}
}