Declaring and Using Variables

Variable declarations are used to identify the type associated with a variable. They can also be used to initialize a variable to a particular value of that type. Variables can be declared as a primitive type or an object type. When a variable is declared as a primitive type, the variable's declaration identifies the type of primitive values that can be stored by the variable. When a variable is declared as an object type, the variable declaration identifies the type of object (that is, class) that can be referenced by the variable.

Java supports two different kinds of variables: field variables and local variables. Field variables are variables that are declared as members of a class. They are also referred to as ...

Get Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams 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.