wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes i am in cofusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "i am in cofusion" Watch "i am in cofusion" New topic
Author

i am in cofusion

ranjan sarkar
Greenhorn

Joined: Jun 30, 2008
Posts: 7
public class name{
......}

in this program if we save it by name11.java then it won't works properly that is
if we change the class name with the file name.

yet in case of
class name{.......}
it will run even if the class name is different it works properly.

so please clear this concept.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by RANJAN SARKAR:
public class name{
......}

in this program if we save it by name11.java then it won't works properly that is
if we change the class name with the file name.

yet in case of
class name{.......}
it will run even if the class name is different it works properly.



Now i am in confusion

note:
--------------------------------
please give meaningful subjectline
---------------------------------
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3429
    
  12
All public classes have to be in a file with the same name as the class. Classes with other access specifiers can be saved in a file of any name.
[ August 05, 2008: Message edited by: Joanne Neal ]

Joanne
ranjan sarkar
Greenhorn

Joined: Jun 30, 2008
Posts: 7
I would like to know why all public classes have to be in a same file.
But not for the other class specifiers
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


I would like to know why all public classes have to be in a same file

Because those are the rules.
[ August 05, 2008: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
 
subject: i am in cofusion
 
Similar Threads
constructor doubt
Strange behavior
ArrayList
Clipboard paradox
how can we view the two lists on a single display???