By Barry Burd

Java is an object-oriented programming language. A program that you create in Java consists of at least one class. A class is like a blank form.

That is, a class is a general description of some kind of thing. In the introduction to this chapter, the class (the form) describes the characteristics that any bag of cheese possesses. But imagine other classes. For example, this figure illustrates a bank account class:

image0.jpg

And this figure illustrates a sprite class, which is a class for a character in a computer game:

image1.jpg

In practice, a class doesn’t look like any of the forms in the figures. In fact, a class doesn’t look like anything. Instead, a Java class is a bunch of text describing the kinds of things that I refer to as “blanks to be filled in.” This listing contains a real Java class — the kind of class you write when you program in Java.

package com.allmycode.andy;
public class BagOfCheese {
  String kind;
  double weight;
  int daysAged;
  boolean isDomestic;
}

As a developer, your primary job is to create classes. You don’t develop attractive online forms like the form in the figure. Instead, you write Java language code — code containing descriptions, like the one in the listing.