字符和连接符(+)
package bilibili;
/**
*
* @ClassName: Main
* @Description:数据类型的注意点
* @author emowater
* @date 2020年6月4日
*
*/
public class Main {
public static void main(String[] args) {
char c ='a';//char类型的数据在进行数学运算时会转换成相应的ASCII码值进行计算
byte b = 2;
int k = b + c;
System.out.println(k);//输出结果为99
String str = "1" + 1 + 2;//双引号括起来的零到多个为字符串
System.out.println(str);//输出结果为112
System.out.println('a'+ 1 + "hello");//输出结果为98hello
String str1 = 1 + 2 + "a" + 3 + 4;
System.out.print(str1);//结果为3a34
//注意:当有一系列的+,如果某部分含有字符串,那么这个字符串前边的的+是数学运算,字符串后的+为拼接
}
}