📄 autotypeconvert.java
字号:
package chapter3;
public class AutoTypeConvert {
public static void main(String[] args) {
char charx = 'h';
int intx = 65;
float floatx = 3.3333f;
double doublex = 4.444;
// char类型的变量charx的值会自动转换为与intx一致的int类型进行计算
int inty = charx + intx;
// int类型的变量值自动转换为float类型参加计算
float floaty = floatx - intx;
// float类型的变量值会自动转换成double类型参加计算
double doubley = doublex / floatx;
System.out.println("inty=" + inty);
System.out.println("floaty=" + floaty);
System.out.println("doubley=" + doubley);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -