Chapter 3. Introduction to Classes, Objects, Methods and Strings

Nothing can have value without being an object of utility.

Karl Marx

Your public servants serve you right.

Adlai E. Stevenson

You’ll see something new. Two things. And I call them Thing One and Thing Two.

Dr. Theodor Seuss Geisel


In this chapter you’ll learn:

• How to declare a class and use it to create an object.

• How to implement a class’s behaviors as methods.

• How to implement a class’s attributes as instance variables and properties.

• How to call an object’s methods to make them perform their tasks.

• What instance variables of a class and local variables of a method are.

• How to use a constructor to initialize an object’s data.

• The differences ...

Get Java™ for Programmers: Deitel Developer Series, Second Edition now with the O’Reilly learning platform.

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