PPT Slide
Instance vs. Class Methods
- Use instance methods whenever each object should have its own behavior.
e.g.,
pickles vs. descartes vs. abby doYourThing( ).
- Use a class method whenever the class itself should maintain a single behavior for all instances of the class.
converting from one type to another.
- Class methods cannot be used to access
instance variables
- So you can sayInteger.valueOf(strValue);but notintObject.valueOf(strValue);