O'Reilly logo

Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition by Rolf W. Rasmussen, Khalid A. Mughal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.22. final Parameters

A formal parameter can be declared with the keyword final preceding the parameter declaration in the method definition. A final parameter is also known as a blank final variable; that is, it is blank (uninitialized) until a value is assigned to it, (for example, at method invocation) and then the value in the variable cannot be changed during the lifetime of the variable (see also the discussion in Section 4.10, p. 146). The compiler can treat such blank final variables as constants for code optimization purposes. Whether a formal parameter is declared as final, does not affect the caller's code.

The definition of method calcPrice() from Example 3.3 is shown below, with the formal parameter pizzaPrice declared as final ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required