Java02-标识符/ 关键字/ 分隔符/ 常量final

1. 标识符,给变量起名

a. 区分大小写
b. _/ $/ 字母/ 数字,数字不可在首位
c. 关键字不可作为标识符

2. 关键字

关键字全是小写的!

数据类型:boolean、byte、char、 double、 false、float、int、long、new、short、true、void、instanceof
语句:break、case、 catch、 continue、 default 、do、 else、 for、 if、return、switch、try、 while、 finally、 throw、this、 super
修饰的关键字有 abstract、final、native、private、 protected、public、static、synchronized(同步)、transient、 volatile
方法、类、接口、包和异常:class、 extends、 implements、interface、 package、import、throws
Java保留的没有意义的关键字:cat、 future、 generic、innerr、 operator、 outer、rest、var
3个保留字(不是关键字,而是文字):true、false、null

3. 分隔符

3.1 分号 ‘;’

一个分号一个句子,无分号就意味着连续
下面两个代码逻辑上是一样的:

	int sum = 1 + 2 + 3 + 4 ;  
	int sum = 1 + 2 +
	3 + 4 ;

4. 常量,用final修饰的变量 就是常量

	final int a = 1 ;
发布了42 篇原创文章 · 获赞 2 · 访问量 1176

猜你喜欢

转载自blog.csdn.net/qq_40893824/article/details/103989880