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