publicclassTest{
publicstaticvoid main(String args[]){
int i =3/2;
System.out.println(i);
}
}
publicclassTest{
publicstaticvoid main(String args[]){
int i =5;
int j = i+++5;
System.out.println(i);
System.out.println(j);
}
}
- 要点三: = 与 == 的区别?
- = :是赋值号,== 是判断左右两边是否相等并返回boolean值。
publicclassTest{
publicstaticvoid main(String args[]){
int i =5;
int j =6;
boolean b = i == j;
System.out.println(b);
}
}
- 逻辑运算符
![](https://images2015.cnblogs.com/blog/1016412/201608/1016412-20160828164920465-1053373419.jpg)
-
- 短路与 a && b,会先判断a的真假,若为假,后面的b不运算。而逻辑与 a & b,都会运算。
- publicclassTest{
- publicstaticvoid main(String args[]){
- boolean a =true;
- boolean b =false;
-
- boolean c = a & b;
- boolean d = a && b;
- System.out.println(c);
- System.out.println(d);
-
- int i =5;
- boolean e = i >6&& i++>7;
- System.out.println(e);
- System.out.println(i);
- }
- }
转载于:https://www.cnblogs.com/arroneve/p/5815362.html