Java基础语法
2.1 Java的注释
范例2-1:单行注释。
public class TestDemo {
public static void main(String[] args) {
// 此处为注释,编译代码时不编译
System.out.println(“Hello World .”);
}
}
范例2-2:多行注释。
public class TestDemo {
public static void main(String[] args) {
/*
* 此处为多行注释,编译代码时不编译
*
/
System.out.println(“Hello world.”);
}
}
范例2-3:使用文档注释。
/*
- 此处为文档注释
- @author xx
*/
public class TestDemo {
public static void main(String[] args) {
System.out.println(“Hello xx.”);
}
}
范例2-4:利用中文定义标识符。
public class 你好 { // 类名称
public static void main(String args[]) {
int 年龄 = 20 ; // 变量名称
System.out.println(年龄) ; // 输出内容
}
}