Static method(Class method) and Instance method
Summary
static method call static method? O
static method use instance variable? X
static method use instance method? X
why? When call static method, object(iv group) might not exist!
Static method = class method
Depend on whether using IV(Instance Variable) or not.
Instance Method
Static Method
call
referencetype_var_name.methodname()
class_name.methodname()
IV(Instance Method)
use IV
Not use and non-related with IV
Static method example : Math.random(). No need to create object(reference type variable).
think about making static method.
=> when NOT using iv and im!
static variable : common properties.
CV(Class variable) , CM(Class Method) are available without creating object
IV, IM are non-available before creating object.
Last updated
Was this helpful?