public class Test001 {
public static Integer count = 0;
public static void main(String[] args) throws Exception {
//ASCII中'a'为97,char类型与int类型进行运算的时候
//char类型会隐式转换成int类型,再进行运算
System.out.println('a'+1);//98
System.out.println((char)('a'+1));// b
System.out.println("hello"+'a'+1);//helloa1
System.out.println('a'+1+"hello");//98hello
System.out.println("5 + 5 ="+5+5);//5 + 5 =55
System.out.println("5 + 5 ="+(5+5));//5 + 5 =10
}
本文详细解析了Java中字符(char)与整数(int)的运算规则,展示了不同类型间的自动转换过程,以及字符串与数值混合运算的特殊表现。通过实例,深入理解Java的数据类型转换与运算符的使用。
1418

被折叠的 条评论
为什么被折叠?



