Section 6.11 Scope of Declarations

• Scope (p. 222) is the portion of the program in which an entity, such as a variable or a method, can be referred to by its name. Such an entity is said to be “in scope” for that portion of the program.

• The scope of a parameter declaration is the body of the method in which the declaration appears.

• The scope of a local-variable declaration is from the point at which the declaration appears to the end of that block.

• The scope of a local-variable declaration that appears in the initialization section of a for statement’s header is the body of the for statement and the other expressions in the header.

• The scope of a method or field of a class is the entire body of the class. This enables a class’s methods ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.