packageoperator;publicclassDemo02{publicstaticvoidmain(String[] args){long a =121321313411L;int b =123;short c =10;byte d =8;System.out.println(a+b+c+d);//longSystem.out.println(b+c+d);//intSystem.out.println(c+d);//int}}
关系运算符
packageoperator;publicclassDemo03{publicstaticvoidmain(String[] args){//关系运算符返回的结果: 正确、错误 布尔值int a =10;int b =20;int c =21;System.out.println(c%a);//取余 模运算System.out.println(a>b);System.out.println(a<b);System.out.println(a==b);System.out.println(a!=b);}}
自增、自减运算符
packageoperator;publicclassDemo04{publicstaticvoidmain(String[] args){//++ -- 自增 自减 一元运算符int a =3;int b = a++;//执行完这行代码后,先给b赋值,再自增int c =++a;//执行完这行代码前,先自增,再给b赋值System.out.println(a);System.out.println(b);System.out.println(c);//幂运算 2^3 2*2*2 = 8double pow =Math.pow(3,2);System.out.println(pow);}}