基本类型 、 字节 、占位数 、 取值范围
1.byte (字节) 、 1 、8 、-2^7~2^7-1
2.short(短整型) 、 2 、 16 、 -2^15~2^15-1
3.int(整数) 、 4 、 32 、-2^31~2^31-1
4.long (长整型) 、 8 、 64 、 -2^63~2^63-1
5.float(浮点型) 、 4 、 32 、 ———
6.double(双精度浮点型) 、8 、 64 、 ———
7.boolean(逻辑型) 、 1 、 8 、 true flase
8.char(字符) 、 2 、 16 、’/u0000’~’/uFFFF’
(注)运算:所以byte、short、char的值将自动提升为int
反之int 转为 byte、short、char需要强转
例1:byte a = 12;
bbb = a + 3;//编译出错
bbb = (byte)a + 3 ; //编译出错
bbb = (byte)(a+3); //正确强转方式
例2:short s = 3;
s = s +3; //编译出错(需要强转)
s +=3; //编译通过(在+=操作的时候会直接转换)
引用类型
1.class
2.interface
3.数组【】
特殊字符
‘ \t ’ tab键
‘ \r ’ return 回车键
‘ \n ’ new line 换行符
++ 、 –
例:++在前
a = 3,b = ++a;
System.out.println(“—b—”+b); //4
System.out.println(“—a—”+a); //4 先运算后赋值
a = 3,b = a++;
System.out.println(“—b—”+b); //3
System.out.println(“—a—”+a); //4 先赋值后运算
instanceof(比较运算符)
例:Object o = “hello”;
System.out.println( o instanceof “引用类型”)