Lesson 3. Working with Objects

Java is an object-oriented programming language. When you do work in Java, you primarily use objects to get the job done. You create objects, modify them, change their variables, call their methods, and combine them with other objects. You develop classes, create objects out of those classes, and use them with other classes and objects.

In this lesson, you’ll work extensively with objects as you undertake these essential tasks:

  • Creating objects

  • Testing and modifying objects’ class and instance variables

  • Calling an object’s methods

  • Converting objects from one class to another

Creating New Objects

When you write a Java program, you define a set of classes. As you learned during Lesson 1, “Getting Started with ...

Get Sams Teach Yourself Java in 21 Days (Covers Java 11/12), 8th Edition 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.