The Concept of Scope

The term scope applies to the visibility of the programming elements within a program. This term is usually applied to the variables within the program. For Java, variables represent either primitive data types or object references. Java provides eight primitive data types: byte, char, short, int, long, float, double, and boolean. Everything else in the Java language is an object reference. Since object references can represent any valid Java class, there is a great deal of flexibility and extensibility in this process. Since for all effective purposes, a Java class is a data type, the Java language is type extensible—whatever data type is needed can be created as a class.

All Java references have some form of scope. For ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software 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.