Java教程

数据类型之间的运算

本文主要是介绍数据类型之间的运算,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
package operator;

import static java.lang.Character.getType;

public class Demo02 {
    public static void main(String[] args) {
        long a = 123123123123123L;
        int b = 123;
        short c = 10;
        byte d = 8;
        double pi = 3.14;
        System.out.println(pi+a+b+c+d);
        System.out.println(a+b+c+d);//long
        System.out.println(b+c+d);//Int
        System.out.println (c+d);//Int     任意非long整数运算,结果总是Int型
    }
}
这篇关于数据类型之间的运算的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!