6.5. Use this and super to access objects and constructors

[7.4] Use super and this to access objects and constructors

In this section, you’ll use the this and super keywords to access objects and constructors. this and super are implicit object references. These variables are defined and initialized by the JVM for every object in its memory.

Let’s examine the capabilities and use of each of these reference variables.

6.5.1. Object reference: this

The this reference always points to an object’s own instance. Any object can use the this reference to refer to its own instance. Think of the words me, myself, and I: anyone using those words is always referring to oneself, as shown in figure 6.24.

Figure 6.24. The keyword this ...

Get OCA Java SE 8 Programmer I Certification Guide now with O’Reilly online learning.

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