Statics



  • Use static methods to implement behaviors that are not affected by the state of any instances.
  • Use static variables to hold data that is class specific as opposed to instance specific—there will be only one copy of a static variable.
  • All static members belong to the class, not to any instance.
  • A static method can't access an instance variable directly.
  • Use the dot operator to access static members, but remember that using a reference variable with the dot operator is really a syntax trick, and the compiler will substitute the class name for the reference variable, for instance: d.doStuff(); becomes: Dog.doStuff();
  • static methods can't be overridden, but they can be redefined.