• Post Reply Bookmark Topic Watch Topic
  • New Topic

error using keyword public  RSS feed

 
vijay nat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got error when i used public keyword in front of class [class box is public should declared in a file named box.java public class box]
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there should not be more than one public class in a *.java file
Make sure the above condition satisfy in your program.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the error message says, Sun's Java compiler insists that a public class named X is stored in a file named X.java . That's just the way it is.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!