运算结果的数据类型

版权声明:转载请注明:beOkWithAnything总结 https://blog.csdn.net/swq463/article/details/84497192
public class javaText {

    public static void main(String[] args) {
        int x = 4;
        System.out.println(" ss" + ((x>4)?99.99:9));
    }
}

程序中99.99是浮点型数,int x = 4是短整型,在和浮点型做运算的时候自动转换成浮点型,在和9做运算的时候,9也自动转换成浮点型了,当然是9.0了

猜你喜欢

转载自blog.csdn.net/swq463/article/details/84497192