• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do we define atmost one public class in our application  RSS feed

 
Shashank Prashar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

how do we define only one public class in our application?
Why can't we define more than one public class in our application?

Warm Regards..
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There can be at most one top-level public class per source file, not per application. There can be multiple classes per source file. Other enclosed classes in a source file may be public. The Java Language Spec may give you further info, depending on what you're looking for. Why do you ask?
 
Shashank Prashar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Greg..

I think i got your point..it means that you are saying in any .java file we can write many classes
but apart from that it should contain only one public class...

right???
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shashank Prashar wrote:Thanks Greg..

I think i got your point..it means that you are saying in any .java file we can write many classes
but apart from that it should contain only one public class...

right???

Only one top level public class.
 
Shashank Prashar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okk..i got it.

Thanks Darryl..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!