正確答案
public class HelloWorld{
??? public static void main(String[] args) {
?? ??? ?String hobby="慕課網(wǎng)";
?? ??? ?System.out.println(hobby);
?? ?}
}
public class HelloWorld{
??? public static void main(String[] args) {
?? ??? ?String hobby="慕課網(wǎng)";
?? ??? ?System.out.println(hobby);
?? ?}
}
2019-08-23
舉報(bào)
2019-08-23
先說一下你的錯(cuò)誤:
你定義了一個(gè)String類型的hobby,但你后面賦值類型確是char型的,而且沒有結(jié)束標(biāo)志";".
你的第五行代碼中hobby變量忘記其類型為String型。
標(biāo)識(shí)符誤用,編譯器識(shí)別不了你的hobby到底是哪一個(gè)。Java中對(duì)大小寫是很敏感的。
改正:
public class HelloWorld{
? ? public static void main(String[] args) {
? ? ? ? char hobby='慕';
? ??
? ? ? ? System.out.println(""+hobby);
? ? ? ? String hobby1="慕課網(wǎng)";
? ? ? ? System.out.println(""+hobby1);
? ? ? ??
? ? }
}