1 public class MyFirstJavaProgram{ 2 public static void main(String[] args ){ 3 System.out.println("Hello World"); 4 } 5 6 }
大小写敏感(case sensitive)——Hello和hello在java中有着不同的意义
所有类名的首字母需为大写(upper case)
所有方法名首字母为小写(lower case)
文件名一般同类名 MyFirstJavaProgram.java
public static void main(String args[]) —— 程序的入口
java标识符(java identifiers)
-
All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_).
- 标识符由A-Z 或 a-z,美元符,下划线为首
-
After the first character identifiers can have any combination of characters.
- 第一个标识符确定后,后面可以为任何字符
-
A key word cannot be used as an identifier.
- 关键字不能作为标识符
-
Most importantly identifiers are case sensitive.
- 大多数标识符是区分大小写
-
Examples of legal identifiers: age, $salary, _value, __1_value 正确例子
- Examples of illegal identifiers: 123abc, -salary 错误例子