1.代码如下
public class temp {
public static void main(String[] args) {
String str = "ABC";
int i = 5;
char ch = 'a';
System.out.println(str + i); //字符串+整型=字符串
System.out.println(str + ch); //字符串+字符=字符串
System.out.println(i + ch); //字符 + 整型= 整型(a在ASCII表里面编号是97)
}
}
2.运行结果如下
ABC5
ABCa
102
附:字符相减转为整型