difference between calling static method and not static method?

Hi,Suppose i want to write a util method, and many class might call this method. what is better? writing the method as static method or not static method. what is the difference. what is the advantace in what case?
[228 byte] By [JavaHeroPrincea] at [2007-11-27 0:50:32]
# 1

> writing the method as static method or not static

> method. what is the difference.

The difference is the one between static and non-static. Any tutorial or the JLs will clarify the difference, no need to repeat it here.

> what is the advantace in what case?

It's usually not like you have much of a choice. If you need access to an instance's attributes, you can't make it static. Otherwise, make it static.

CeciNEstPasUnProgrammeura at 2007-7-11 23:20:39 > top of Java-index,Java Essentials,Java Programming...
# 2

If the utility method will not depend on the value of a particular instance, and will not need to access the value of a particular instance (i.e. non-static data member), it would make sense to make that method static.

Then the functionality you will be offering will conceptually belong to the class, not instances of that class. Think java.lang.Math, for example.

karma-9a at 2007-7-11 23:20:39 > top of Java-index,Java Essentials,Java Programming...
# 3
ya thanks guys
JavaHeroPrincea at 2007-7-11 23:20:39 > top of Java-index,Java Essentials,Java Programming...
# 4
thanks man
JavaHeroPrincea at 2007-7-11 23:20:39 > top of Java-index,Java Essentials,Java Programming...