Chapter 18

Using Methods and Variables from a Java Class

In This Chapter

arrow Using Java’s String class

arrow Calling methods

arrow Understanding static and non-static methods and variables

arrow Making numbers look good

I hope you didn’t read Chapter 17 because I tell a big lie in the beginning of the 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®, 3rd 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.