up previous next contents
Next: Initialization Blocks Up: Classes and objects Previous: Overriding methods   Contents

Static members

  • A static member is a member that exists only once per class, as opposed to once per object.
  • When you declare a field to be static, that means that this field exists only once per class, as opposed to once for each object (such as the nextID field of the Body object).
  • A static method is invoked on behalf of the entire class.
  • A static method can access only static variables and static methods of the class.
        prime = Primes.nextPrime();
        id = Vehicle.currentID();
    


up previous next contents
Next: Initialization Blocks Up: Classes and objects Previous: Overriding methods   Contents