This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Originally posted by ashok reddy devaram: ... The main thing is when u have a public Access modifier infron of a class then u must write the "main()" method in that class only...
Well, if you have a top-level class or interface that's declared public in a Java file, then the file must share that same name, so you would compile using that file name.
However, any class can contain a main method. And once you have your class files compiled, you can run whichever you choose.
For example, the following can be saved in a single file called TestA.java...
You would compile with javac TestA.java, because that's the name of the file. But both of these classes have main methods, so once compiled, you can run either java TestA or java TestB.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
harish shankarnarayan
Ranch Hand
Joined: Sep 12, 2005
Posts: 158
posted
0
if file saved as testB.java remove public from testA write super.mytest() and comment Sys.out.prin(mytest());
as this function takes String as arguments but here its void
now it compiles fine.
Harish<br />SCJP 1.4 (85%)
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.