File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes to define methods as static or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "to define methods as static or not" Watch "to define methods as static or not" New topic

to define methods as static or not

peter brews

Joined: Feb 11, 2002
Posts: 20
Following is the program that I wrote for Socket client.
In method2 of the program i am instantiating the class MyClass
and then calling all the methods as <obj>.<methodname> in this method. This method2 will be called with different params .
Could you please advise me if it is possible/better if instead of instatiating the class i make all those methods as static.

(edited by Cindy to format code)
[ April 11, 2002: Message edited by: Cindy Glass ]
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
If you make them static then you have to watch your synchronization. But WHY would you do either?
If someone called this class, why don't you just use the "this" instance to call the methods?

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: to define methods as static or not
It's not a secret anymore!