給出以下程序的結果:
?1?String?str?=?5+1+"6"+'a';
?2?System.out.println(str);
?3?String?str1?=?5+1+'a'+"6";
?4?System.out.println(str1);
?5?String?str2?=?5+new?Integer(1)+"2"+'4'+new?Long(11);
?6?System.out.println(str2);
?7?String?str3?=?new?Integer(1)+new?Long(11);
?8?System.out.println(str3);
?9?String?str4?=?new?Integer(1)+new?Long(11)?+?'4'?+?"";
10System.out.println(str4);
java的 + 操作符是從左到右依次運算的,+號左右都是整數則做加法運算,+號左右如果有字符串則做連接運算。
注意str和str1的結果是不同的!
str3是編譯通不過的!