Parameters, Local Variables, and Overloading

This chapter reviews method parameters and local variables, as well as method overloading and method signature.

Method overloading means two or more methods have the same name but have different parameter lists: either a different number of parameters or different types of parameters. When a method is called, the corresponding method is invoked by matching the arguments in the call to the parameter lists of the methods. The name together with the number and types of a method's parameter list is called the signature of a method. The return type itself is not part of the signature of a method.

1. Parameters, Local Variables, and Overloading

The state of an object consists of the data it holds in its instance variables. Instance variables hold their values until they are explicitly changed or until the object is destroyed.

An object's methods frequently work with other values that are not held in instance variables. These values are held in local variables and parameters. This chapter discusses how these are declared and used.


Chapter Topics:

  • Formal and Actual Parameters
  • Scope of Parameters
  • Local Variables
  • Scope of Local Variables
  • Method Overloading
  • Signature of a Method


Question 1:

(Review:) What is a parameter of a method?


Source: Bradley Kjell, http://programmedlessons.org/Java9/chap51/ch51_01.html
Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 License.