标签:基本数据 ascii col 字符 style int main family 数据类型
1. char类型 + char 类型 = 字符对应的ASCII码值相加(数字);
char类型 + String 类型 = 字符对应的ASCII码值相加(数字) + String 类型;
String 类型 + char类型 = String 类型 + char类型对应的字符;
1 public static void main(String[] args) { 2 3 char a = ‘A‘; 4 5 char b = ‘B‘; 6 7 System.out.println("a = " + a + ",b = " + b); 8 9 System.out.println( a + b + "1234"); 10 11 System.out.println("" + a + b + "1234"); 12 } 13 14 //运行结果 15 //A的ASCII值:65; 16 //B的ASCII值:66; 17 18 a = A,b = B 19 1311234 20 AB1234
2. 两个char类型比较: == (基本数据类型相比较)
1 public static void main(String[] args) { 2 3 char a = ‘A‘; 4 5 char b = ‘B‘; 6 7 char c = ‘A‘; 8 9 System.out.println(a + b ); 10 System.out.println(a == c); 11 } 12 13 14 //运行结果 15 131 16 true
标签:基本数据 ascii col 字符 style int main family 数据类型
原文地址:https://www.cnblogs.com/BenNiaoXianFei/p/12660449.html