Chapter 8. Variables
In Chapter 7 we discussed how classes could define fields as members of the class. You may be more familiar with the term variable. A variable is a storage location. A variable always has a type associated with it. A variable of primitive type holds the value of a primitive type. A reference type variable holds either a null reference or a reference to an object of the same type as the variable. There are seven kinds of Java variables. Fields, depending on how they are declared, represent two of them. Fields that are declared as static are called class variables. Fields not declared as static are called instance variables. The other Java variable types are array components, method parameters, constructor parameters, exception ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access