第二章Jαv语法基础 JAVA 1.词法规则 2.数据类型 3.常量与变量 4.运算符和表达式 5.语句 6.数租和字符串
1 第二章 Java语法基础 1. 词法规则 2. 数据类型 3. 常量与变量 4. 运算符和表达式 5. 语句 6. 数组和字符串
词法规则 JAVA 丁av程序的运行体系 1. Source code(java file) 2. javac: Lexical analysis parsing Type-checking Byte code( class file) Jαv編译器对源代码进行闹法分析和类型校验,生成 字节码文件 3. JVM: Verification(essentially repeating static checks +(interpretation OR Compilation Loading Executing) Jαv解释器执行字节码文件中的类,Jαv解释器在加 载和执行类时验证类的完整性、正确操作和安全性 并与所在的操作系统、窗口环境和闼辂设备进行交互 以产生所期望的程序行为
2 词法规则 ◼ Java程序的运行体系 1. Source code (.java file) 2. javac: Lexical Analysis & Parsing + Type-checking → Byte code (.class file) Java编译器对源代码进行词法分析和类型校验,生成 字节码文件 3. JVM: Verification (essentially repeating static checks) + (Interpretation OR Compilation + Loading + Executing) Java解释器执行字节码文件中的类,Java解释器在加 载和执行类时验证类的完整性、正确操作和安全性, 并与所在的操作系统、窗口环境和网络设备进行交互 以产生所期望的程序行为
关键字 JAVA abstract double strictfp 米水 2. boolean else interface super 3. break extends long switch 4. byte final native synchronized 5. case finally new this 6. catch float package throw 7. char private throws 8 class goto protected transient 9. const if public 10. continue implements return void 1. default import short volatile 2. do instanceof static While 淮:*→当前未被使用大*→>使用于Jαva2
3 关键字 1. abstract double int strictfp ** 2. boolean else interface super 3. break extends long switch 4. byte final native synchronized 5. case finally new this 6. catch float package throw 7. char for private throws 8. class goto * protected transient 9. const * if public try 10. continue implements return void 11. default import short volatile 12. do instanceof static while 注: *→当前未被使用 * *→使用于Java2
标识符 AvA 标织→常量、变量、数据类型、类和方法 public class helloWorld1 i public static void main(stringl] argsi String message= Hello world! myPrint(message) private static void my Print(string st System. out. printIn(s);
4 标识符 ◼ 标识→常量、变量、数据类型、类和方法 public class HelloWorld1 { public static void main(String[] args) { String message = “Hello World!”; myPrint(message); } private static void myPrint(String s) { System.out.println(s); } }
标识符 JAVA 组成规则 1.字母(A~Z、α~z)、特殊符号($、_)和 数字(0~9) 2.第1个符号不能为数字 3.不能为关键词:比如true、 false、mul 4.严格区分大小写
5 标识符 ◼ 组成规则 1. 字母(A~Z、a~z)、特殊符号($、_)和 数字(0~9) 2. 第1个符号不能为数字 3. 不能为关键词:比如true、false、null 4. 严格区分大小写