Hey all, I have a simple doubt regarding performance. Suppose i am having a common class which contains some common methods. Now i need to use common methods in my specific class. Which way is better? 1) Extend the super class which contains common methods and there by we can just call those methods. 2) The commom class contains methods which are public static, so just call them by Class.methodname
The decision of extending a class should be based on whether the "specific" class that you are talking about would make any design sense by being made as a sub-class of the other class (which has those methods). However, if you are thinking of inheritance just in order to use those methods, then that would be just a "quick-and-dirty" inheritance. Simple thing...don't go for it because you yourself will get confused when you are trying to make sense out of the whole code at a later point (not to mention your fellow programmers ;-) )
If both the classes have no hierarchical sense, then go with the second method. If you have declared the methods to be static, then they will neither be stored in the heap nor the stack nor the constant storage...they go into a different type of storage, in the RAM, called "static storage". So I don't think this approach will be a hit on the performance.
Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
In my experience, best perforances come from improved algorythms and rarely from "technical tricks". As a programmer, you want surely know more on how java compilers manage your code. However, don't expect too much time gain using this knowledge ;-)