guojiayi

1.Java中的加法的运算优先级是从左往右的

2.字符串""隔壁跟的+号意思是字符串的连接 就不是加法了

3.\'字符\' 后面的+号意思是\'字符\'的ascall码值和后面的值相加

class DataTypeDemo9 {
	public static void main(String[] args){
		System.out.println("hellow"+\'a\'+\'1\');   // 输出helloa1
		System.out.println(\'a\'+1+"hello");       // 输出为98hellow  (\'a\'=\'A\'+\'0\'  ,97 = 65 + 32  )(97+1 再连接hellow 字符串)
		System.out.println("5+5="+5+5);        // 输出为字符串5+5=55(字符串的连接)
		System.out.println(5+5+"=5+5");        // 输出为10=5+5  (先算出5+5的运算 得出10再连接字符串"5+5")
		
		
	}
}  

分类:

技术点:

相关文章: