8.7. Reference Types

Values that are objects (i.e., class instances or arrays; anything nonprimitive) are known as reference values or simply references. In the Java world, we normally say that the value of such and such a variable “is” an object. Because the Java programming language has no explicit referencing or dereferencing of pointers or pointer arithmetic, it is commonly but erroneously stated that Java does not have pointers. Wrong! In fact, all nonprimitive variables in Java are pointers. So, a C programmer might find it clearer to say that such and such a nonprimitive variable “points to” an object. This is the only kind of nonprimitive type in Java; there is no distinction between variables that are objects and variables that point ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

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