英文:
Why these errors <identifier> expected and ';' expected are occurring in below code?
问题
Code:
class Singleton{
public String str = "";
private Singleton() { }
public static Singleton getSingleInstance() {
return new Singleton();
}
}
Error message:
Main.java:10: error: ';' expected
public String str = "";
^
Main.java:10: error: <identifier> expected
public String str = "";
^
Question: Why these errors 1) <identifier> expected
and 2) ';' expected
are occurring in the code below?
英文:
Code :
class Singleton{
Public String str="";
Private Singleton()
{ }
public static Singleton getSingleInstance()
{
return new Singleton();
}
}
Error message:
Main.java:10: error: ';' expected
Public String str="";
^
Main.java:10: error: <identifier> expected
Public String str="";
^
Ques:Why these errors 1) <identifier> expected and 2)';' expected are occurring in below code?
答案1
得分: 1
Java是区分大小写的;关键字是public
。不是Public
。
英文:
Java is case sensitive; the keyword is public
. Not Public
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论