Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

main and other methods in same file?

 
Sam Bluesman
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to have them within a class definition.
 
Sam Bluesman
Ranch Hand
Posts: 191
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"them" ? Whast is them. I just want to print out Hello!

Cheers
 
Keith Lynn
Ranch Hand
Posts: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The methods and main method all have to be within class definitions.
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I might be missing the point, but does this help?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic