【发布时间】:2020-06-13 07:13:24
【问题描述】:
在数据类型层次结构中,char 在 int 之前,因此需要将 int 类型转换为 char 才能将其转换为 char。但是当我在sn-p上面运行时,它没有报错,并且成功输出为A。我能知道原因吗?
public class ecd {
public static void main(String[] args) {
char a; a = 65;
System.out.print(a);
}
}
【问题讨论】:
-
包 abc;公共类 ecd { public static void main(String[] args) { char a; a = 65; System.out.print(a); } }
-
通过编辑在问题中添加代码sn-p
-
同时更正标题和问题中的错字 - 对话 -> 转换
标签: java casting type-conversion typecasting-operator