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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.