package com.lirun.operator;
public class Demo01 {
public static void main(String[] args) {
int a = 10;
int b = 20;
int c = 25;
int d = 25;
System.out.println(a+b);//30
System.out.println(a-b);//-10
System.out.println(a*b);//200
System.out.println(a/(double)b);//0.5 double比int优先级高,有double和int输出类型就是double
}
}
package com.lirun.operator;
public class Demo02 {
public static void main(String[] args) {
long a = 12312312313L;
int b = 123;
short c = 10;
byte d = 8;
System.out.println(a+b+c+d);//lang,当long、int、short、byte类型在一起时输出类型为long类型
System.out.println(b+c+d);//int,当int、short、byte类型在一起时输出类型为int类型
System.out.println((c+d));//int,当short、byte类型在一起时输出类型为int类型
}
}