這是什么問題呢?謝謝大神們
1, ?public class HelloWorld{ ? ?public static void main(String[] args) { String hobby="慕課網(wǎng)"; System.out.println(+hobby); } } 2, ?public class HelloWorld{ ? ?public static void main(String[] args) { String hobby="慕課網(wǎng)"; System.out.println(""+hobby); } } 第一個不能執(zhí)行第二個可以不加“”為什么就不對?
2017-05-26
public class HelloWorld{
? ? public static void main(String[] args) {
String hobby="慕課網(wǎng)";
System.out.println(hobby);
}
}
這就可以了 加之類的輸出根本不需要 ?下面已經(jīng)有輸出了 輸出的變量為 hobby
2017-05-23
+在這里表示拼接字符串,將變量hobby的值拼接到+前面的字符串后面,+前面沒有字符串的話就會報錯了
2017-05-23
The operator + is undefined for the argument type(s) String