标识符和关键字
标识符
关键字
| abstract |
assert |
boolean |
break |
byte |
| case |
catch |
char |
class |
const |
| continue |
defauit |
do |
double |
else |
| enum |
extends |
final |
finally |
float |
| for |
goto |
if |
impiements |
import |
| instanceof |
int |
interface |
long |
native |
| new |
package |
private |
protected |
public |
| return |
strictfp |
short |
static |
super |
| switch |
synchronized |
this |
throw |
throws |
| transient |
try |
void |
volatile |
while |
- Java所有的组成部分都需要名字、类名、变量名以及方法名都被称为标识符
- 所有的标识符都应该以字母(A-Z或者a-z),美元符($)、或者下划线(_)开始
- 首字符之后可以是字母(A-Z或者a-z),美元符($)、或者下划线(_)或数字的任何字符组合
- 不能使用关键字作为变量名或方法名
- 标识符是大小写敏感的
- 合法标识符举例:age、$salary、_value、__1_value
- 非法标识符举例:123abc、-salary、#abc
- 可以使用中文命名,但一般不建议这样使用
public class Demo01 {
public static void main(String[] args) {
String 王者荣耀 ="百星王者";
System.out.println(王者荣耀);
//大小写十分敏感
String Man ="小马";
String man ="小马";
String Ahello ="小马";
String ahello ="小马";
String $hello ="小马";
String _hello ="小马";
}
}