Review:   Java classes and methods

  • Recall:

    • A class in Java contains variables and methods:

    • A method contains statements that performs an important task

  • There are 2 kinds of methods in a class:

    • Static methods (a.k.a. class methods)
    • Instance methods

  Static and instance methods  

  • Static methods (or class methods):

    • Static method = a method whose behavior is determined by:

      • The arguments passed to the method only


  • Instance methods:

    • Instance method = a method whose behavior is determined by:

      • The arguments passed to the method            and

      • The instance of the object passed to the method