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 ...

Get Technical Java™: Developing Scientific and Engineering Applications 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.