up previous next contents
Next: Overloading methods Up: Classes and objects Previous: Methods   Contents

this

  • Typically use this only when needed.
  • Most commonly used as a way to pass a reference to the current object as a parameter to other methods.
  • Often used in a case like this:
      class Pizza
      {
          String topping;
          Pizza (String topping)
          {
              this.topping = topping;
          }
      }
    


up previous next contents
Next: Overloading methods Up: Classes and objects Previous: Methods   Contents