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