aspose file tools*
The moose likes Beginning Java and the fly likes main and other methods in same file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "main and other methods in same file?" Watch "main and other methods in same file?" New topic
Author

main and other methods in same file?

Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
For argument's sake, say I have 2 methods that do something called Method1() and Method2(). How do i put the main method in the same file at the bottom so that I only need the one file to compile and run? The main method wouldnt actaully do much except allow the compiler to see that a main method was present.

e.g.

Method1()
.
.
.
Method2()
.
.
.

Where would 'main' go and what would it contain?

Cheers
[ February 27, 2006: Message edited by: Sam Bluesman ]

Moosey knows best
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
You have to have them within a class definition.
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
"them" ? Whast is them. I just want to print out Hello!

Cheers
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
The methods and main method all have to be within class definitions.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I might be missing the point, but does this help?


"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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: main and other methods in same file?