变量:全局变量,成员变量
- byte[1],short[2],int[4],long[8];char[2];folat[4],double[8];boolean[1]
- 浮点型:符号位+指数位+尾号位》》》》》”易精度损失”
- 表示形式:.232或1.2E3(1.2x10^3)
- 8.3/3=2.766666666666667,所以浮点数比较,对差值进行评估
- Char:对应uincode码
- byte ,short ,char 之间转换需要转换为
int进行转换
String与基本数据类型转换:
- 转String:
String s = 123+""; - 转基本数据类型:
int i = Integer.parseInt("123");
charAt()与int转换:
int a = s.charAt(0) - '0';int b = Integer._parseInt_(String._valueOf_(s.charAt(1)));
逻辑运算
- 逻辑(&、|、):条件都会进行判断
- 短路(&&、||、):满足一半即可判断,则不会判断后面的条件
-
复合运算:默认有个强制转换
byte a =1 ; a+=1; 等价于 a =(byte)a+1;a++; 等价于a =(byte)a+1三元运算:表达式类型1和表达式类型2”要与接受变量类型兼容”
循环
一、for(;i<10;):把变量i定义在外面
二、for(;;):无限循环
三、for(int i = 0,int j = 0 ;i <10 ; i++,i += 2 )
break
//不推荐使用,若没有带标签,默认最近的循环//continue也一样public static void main(String[] args) {title: for(int i = 0;i<10;i++){title1: for (int j = 0;j<10;j++){if (i == 6)break title;}}}
return:用在方法时,跳出当前方法;在main方法中,结束进程
二维数组
- 根据需求设置列数
int[][] a = new int[10][];a[i] = new int[i+1];
