Chapter 18

Using Methods and Fields from a Java Class

IN THIS CHAPTER

check Using Java’s String class

check Calling methods

check Understanding static and non-static methods and fields

check Making numbers look good

Ihope you didn’t read Chapter 17, because I tell a big lie at the beginning of that chapter. Actually, it’s not a lie. It’s an exaggeration.

Actually, it’s not an exaggeration. It’s a careful choice of wording. In Chapter 17, I write that the gathering of data into a class is the start of object-oriented programming. Well, that’s true. Except that many programming languages had data-gathering features before object-oriented programming became popular. Pascal had records. C had structs.

To be painfully precise, the grouping of data into usable chunks is only a prerequisite to object-oriented programming. You’re not really doing object-oriented programming until you combine both data and methods in your classes.

This chapter starts the data-and-methods ball rolling, and Chapter 19 rounds out the picture.

The String Class

The String class is declared in the Java API. This means that somewhere ...

Get Beginning Programming with Java For Dummies, 5th 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.