Originally posted by Manfred Leonhardt:
The obvious advantage is that there will only be one method in memory regardless of how many objects of the class exist in memory.
"JavaRanch, where the deer and the Certified play" - David O'Meara
Originally posted by Marilyn Monickam:
That is why I want to know what the advantage is. Does it reflect on the performance if I create an object and then invoke the method.I don't think so.
Marilyn
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Campbell Ritchie wrote:I don't believe there is any "advantage" to making methods static.
Methods which affect or use instance fields or state must not be static; methods which do not affect or use instance information can beneficially be declared static.
Methods are loaded into the Method area when a class is loaded. They are not replicated for each instance created
Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Campbell Ritchie wrote:By the way: java.lang.Math isn't an abstract class. It is uninstantiable, but that is quite different from abstract.
Campbell Ritchie wrote:I hope you are not going to write a Math class; you get no end of confusion of you write classes with the same name as java.lang classes.
Can't .... do .... plaid .... So I did this tiny ad instead:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|