Chapter 1: All About Java 21 Close your eyes for a minute and think about what it means for something to be a chair. . . . A chair has a seat, a back, and legs. Each seat has a shape, a color, a degree of softness, and so on. These are the properties that a chair possesses. What I describe is chairness the notion of something being a chair. In object- oriented terminology, I m describing the chair class. Now peek over the edge of this book s margin and take a minute to look around your room. (If you re not sitting in a room right now, fake it.) Several chairs are in the room, and each chair is an object. Each of these objects is an example of that ethereal thing called the Chairclass. So that s how it works the class is the idea of chairness, and each individual chair is an object. A class isn t quite a collection of things. Instead, a class is the idea behind a certain kind of thing. When I talk about the class of chairs in your room, I m talking about the fact that each chair has legs, a seat, a color, and so on. The colors may be different for different chairs in the room, but that doesn t matter. When you talk about a class of things, you re focusing on the properties that each of the things possesses. It makes sense to think of an object as being a concrete instance of a class. In fact, the official terminology is consistent with this thinking. If you write a Java program in which you define a Chairclass, each actual chair (the chair that you re sitting on, the empty chair right next to you, and so on) is called an instance of the Chairclass. Here s another way to think about a class. Imagine a table displaying all three of your bank accounts. (See Table 1-1.) Table 1-1 A Table of Accounts Account Number Type Balance 16-13154-22864-7 Checking 174.87 1011 1234 2122 0000 Credit 471.03 16-17238-13344-7 Savings 247.38 Think of the table s column headings as a class, and think of each row of the table as an object. The table s column headings describe the Accountclass. According to the table s column headings, each account has an account number, a type, and a balance. Rephrased in the terminology of object- oriented programming, each object in the Accountclass (that is, each
Are you a Mac user in a search of Mac web hosting provider? We are. once upon a time, we were just like you, trying to find somebody who knows. Unfortunately, we had no luck, so we decided to help many others like you, and us. our team developed Mac friendly web hosting plans, feature packed, constantly monitored, and more than affordable. With us, you are home. Sign up.