package operator;public class Demo02 {public static void main(String[] args) {long a = 121212121212121L;int b = 100;short c = 10;byte d = 8;double e = 20.1;float f = 1.1F;System.out.println(a + b + c + d);//longSystem.out.println(b + c + d);//intSystem.out.println((c + d);//intSystem.out.println(a + b + e);//doubleSystem.out.println(a + b + f);//floatSystem.out.println(e + f);//double}
}
/*
121212121212239
118
18
1.212121212122411E14
1.2121212E14
21.20000002384186
*/
关系运算符
关系运算符返回的结果为布尔类型;
package operator;public class Demo03 {public static void main(String[] args) {int a = 10;int b = 20;int c = 21;System.out.println(a > b);System.out.println(a < b);System.out.println(a == b);System.out.println(a != b);System.out.println(c % a);//取余 模运算}
}
/*
false
true
false
true
1
*/
自增++ 自减-- 一元运算符
++a 是先计算后赋值,a++ 是先赋值后计算;
package operator;public class Demo04 {public static void main(String[] args) {int a = 3;int b = a ++;int c = ++ a;System.out.println(a);//5System.out.println(b);//3System.out.println(c);//5}
}
/*
5
3
5
*/