SpletA Java class doesn't need to be declared static. The problem is that it needs to be in a file with the same name as the only public class in the file. You can get it to compile by declaring class Temperature to not be public. I just tested that you can still compile a program with the wrong filename and with no public class in the file in question. Splet15. jun. 2013 · test.java:1: error: class Simple is public, should be declared in a file named Simple.java public class Simple 然后我才改的。 。 System.out.println ()是我在这里提问时候漏掉了这个忽略 2 评论 (1) 分享 举报 更多回答(2) 2015-05-14 java error:‘;’ expected 我这个问题在... 1 2008-05-03 java程序中 ')' expected 是什么错提示 2014-01-11 java 编译 …
java - Проблема class ... is public should be declared in a file named …
SpletHelloworld.java:1: Error: Class HelloWorld is public and should be declared in a file named Helloworld.java HelloWorld At that time do not know what this error means, always thought that the program inside what is missing a statement. (then the brain emerges similar to a microcontroller program that needs to be declared again). Splet30. apr. 2012 · As the error message implies, if you declare a class as public, it needs its own .java file. If you don't want to do that, then don't define it as public. Share Improve this answer Follow answered Apr 29, 2012 at 23:52 Oliver Charlesworth 266k 32 560 677 1 Is … door bell push battery
JavaのコードでEclipse上ではコンパイルエラーは起こらないが他 …
SpletThis is how the creators of the Java environment saw it fit so you must follow the rules... With that said it is possible to declared multiple entities within a source file but only one can be declared as public and the actual source file must be named after that publicly declared entity... Jesper de Jong Java Cowboy Posts: 16084 88 I like... SpletThe first thing I'm going to do is, create a banking project. So any clips, File > New > Java Project. We'll call it Banking. Click the next button. I'm going to uncheck the Create module -info.Java file. Finish. Then I'm going to create my first … Splet17. apr. 2024 · Main.java:2: class main is public, should be declared in a file named main.java public class main . 搜了很多解决办法,都是说类名要和文件名改成一样的,明明我改的确实是一样的鸭。。我还问了强者大哥大姐们,怎么改都是报这个错(;′⌒`) 。。。。 … doorbell push button case