Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JAVA Source file name and Public Modifier

Status
Not open for further replies.

munnanext

Programmer
Aug 20, 2004
49
US
I read that Java Source Fiel can have any number of classes and the Surce File name shoul be having a match to at least one Publci Class in the Source.

For Eg:

my Java Source file name is Example.java.
here is the source

class Example{}
class SomeotherClass{}

When I compile this it is not giving me Compilation error. I am expecting Compilation error becasue Example should be Public. ANd one more question is the order make sence to the compier ?

Thanks for solution
 
None of the classes have to be public.

The compiler does not care which "way round" the classes are declared.

Bear in mind though that it is normal practice to have one class per file (not including inner classes).

--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top