+ 1
question about running java in Dcoder
public class ExampleProgram { public static void main(String[ ] args) { System.out.println("Hello World"); } } I ran this code in Dcoder java ide,and got this output:source_file.java:1: error: class ExampleProgram is public, should be declared in a file named ExampleProgram.java public class ExampleProgram { ^ 1 error I do save the file with the same name of the class "ExampleProgram",so did I miss something else to make it work.
3 Antworten
+ 4
OK,I found the answer,it should be
"class Dcoder" not "public class" ,not other class name in main
+ 1
I saved the file as you said and it didn't work,then I intent to move the file from Dcoder work folder to somewhere like /sdcard in my phone for compiling it ,but it is not permitted
0
Save it as ExampleProgram.java this is the way it should work.