1.关键字
| abstract | assert | boolean | break | byte |
|---|---|---|---|---|
| case | catch | char | class | const |
| continue | default | do | double | else |
| enum | extends | final | finally | float |
| for | goto | if | implements | 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 所有的组成部分都需要名字。类名,变量名以及方法名都被称为标识符。
2.标识符
-
所有的标识符都应该以字母(A-Z或者a-z),美元符($),或者下划线(_)开始
-
首字母之后可以是字母(A-Z或者a-z),美元符($),或者下划线(_)或数字的任何字符组合
-
不能使用关键字作为变量名或方法名
-
标识符是大小写敏感的
-
合法标识符举例:age,$salary,_value,__1_value
-
非法标识符举例: 123abc,-salary,#abc
-
可以使用中文命名,但是一般比建议使用,也不建议使用拼音,很low
public class Demo01 {
public static void main(String[] args) {
String 王者荣耀 = "百星王者";
// String 王者荣耀 = "倔强青铜";
System.out.println(王者荣耀);
//大小写十分敏感
String Man = "xiexiaoran";
String man = "xiexiaoran";
String name = "xiexiaoran";
String Ahello = "xiexiaoaran";
String hello = "xiexiaoaran";
String $hello = "xiexiaoaran";
String _hello = "xiexiaoaran";
String _ ="xiexiaoran";
//String class ="xiexiaoran";
//String 1hello = "xiexiaoaran"
//String #hello = "xiexiaoaran"
//String *hello = "xiexiaoaran"
}
}
数据类型
1.强类型语言
要求变量的使用严格符合规定,使用变量都必须先定义后才能使用
2.Java的数据类型分为两大类
-
基本类型(primitive type)
-
应用类型(reference type)
public class Demo02 {
public static void main(String[] args) {
//八大基本数据类型
//整数
int num1 =10; //最常用
byte num2 =20;
short num3 =30;
long num4 =30L; //类型要在数字后面加个L
//小数:浮点数
float num5 =50.1F;
double num6 =3.1415926
//字符
//char name = 'A';
//字符串,String不是关键字,类
//String namea = "谢小然";
//布尔值
boolean flag = true;
//boolean flag = flase;
}
}



