目录

helloworld.java1-错误-类HelloWorld是公共的,-应在名为-HelloWorld.java-的文件中声明-public-class-HelloWorld

目录

helloworld.java:1: 错误: 类HelloWorld是公共的, 应在名为 HelloWorld.java 的文件中声明 public class HelloWorld

http://static.blog.csdn.net/xheditor/xheditor_emot/default/awkward.gif http://static.blog.csdn.net/xheditor/xheditor_emot/default/awkward.gif http://static.blog.csdn.net/xheditor/xheditor_emot/default/awkward.gif

在cmd命令行中,使用javac编译时(javac helloworld.java),出现这样的提示错误:

helloworld.java:1: 错误: 类HelloWorld是公共的, 应在名为 HelloWorld.java 的文件中声明 public class HelloWorld

这个问题是,当类设置public时,public设置的那个类必须与文件名相同。

javac HelloWorld.java 这样编译就不会出现了

http://static.blog.csdn.net/xheditor/xheditor_emot/default/bye.gif 没爱了。。。。。