Accessing an object in Java

To access the method of the class, we write the object name and then . (dot). All the methods that qualify for the class are displayed in a drop-down—this is another great feature in Eclipse. We can just look for the method in the drop-down rather than searching for it through the code.

In the example, we are using the getData() method. The rest of the methods shown are all built-in Java methods. Observe how the methods are displayed:

Drop-down showing all the class methods available to the editor to use

On clicking on getData(), the getData() block will be transferred to the line where the object was called, and ...

Get Hands-On Automation Testing with Java for Beginners 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.