Understanding classes
Java, as with other OO languages, uses a syntax that revolves around the source code structure called a class. But first, what is a class? The theorists who introduced the concept of objects envisioned a class as a custom data type. Think of the primitive integer type–it has a range of allowable values and a pre-defined set of operations such as addition, subtraction, and the other usual operators. Imagine a class as a custom primitive in which you decide which operations, in the form of methods, your type will perform. One goal of OOP is to focus on problem-solving by developing custom data types that combine data and actions as opposed to the structured programming approach where data and actions are separate.
This means that you develop a class by first listing all the fields of the class, either primitives or references to other classes. Next come the methods that conduct useful tasks that make use of these fields. These variables are visible to...