Java: when to use static methods

Posted by KP65 on Stack Overflow See other posts from Stack Overflow or by KP65
Published on 2010-04-19T23:05:33Z Indexed on 2010/04/20 0:03 UTC
Read the original article Hit count: 238

Filed under:
|

Hello,

I am wondering when to use static methods? Say If i have a class with a few getters and setters, a method or two, and i want those methods only to be invokable on an instance object of the class. Does this mean i should use a static method?

e.g

Obj x = new Obj();
x.someMethod

or

Obj.someMethod

(is this the static way?)

I'm rather confused!

© Stack Overflow or respective owner

Related posts about java

Related posts about static-methods