• Post Reply Bookmark Topic Watch Topic
  • New Topic

reg public class in a java source code  RSS feed

 
Manoj Kumar Ravikanti
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why only one public class should be defined in a java 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
A program may consist of any number of classes, any number of which may be public. An individual source file can contain only one public class; this is really just a convenience for the compiler implementor, and there's no extremely convincing reason for it. A real program typically consists of many, many source files.
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it's so that each public class can have an entry point for the class file. This allows you to test each class file using this entry point.

-- Kaydell
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!