Files
javaSE251223/day02/src/com/inmind/Demo02.java
2025-12-23 15:25:13 +08:00

19 lines
548 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.inmind;
/*
自动类型转换规则
范围小的类型向范围大的类型提升byte、short、char 运算时直接提升为int 。
自动提升规则:
byte、short、char-->int-->long-->float-->double
注意当java的不同类型进行计算时自动先提升为大范围的类型
*/
public class Demo02 {
public static void main(String[] args) {
//定义一个double型的变量
double d = 3.5;
float b = 100;
double sum = b+d;
System.out.println(sum);
}
}