com.xu.operator.Demo02
作者:互联网
package com.xu.operator;
public class Demo02 {
public static void main(String[] args) {
long a=123123123123123L;
int b=123;
short c=10;
byte d=8;
System.out.println(a+b+c+d);//long
System.out.println(b+c+d);//int 141
System.out.println(c+d);//int 18
System.out.println((double)c+d);//18.0
System.out.println(c);// 10
System.out.println(d);// 8
/*
操作数中有一个为long,则结果为long;若操作数中无long,
则结果为int,此时不管操作数中是否有int数据;但是若是有浮点数,
仍旧是浮点类型;
*/
}
}
\Desktop\JavaSE\out\production\基础语法" com.xu.operator.Demo02
123123123123264
141
18
18.0
10
8
Process finished with exit code 0
标签:int,System,long,Demo02,operator,println,xu,com,out 来源: https://www.cnblogs.com/xunzhao26/p/14802839.html