There is no need to import java.lang.* because classes in that package are imported by default. But that's how we import classes in general. Java programs are made out of classes. This program is made out of one class only. It has the following basic structure: import java.lang.*; public class CheckerBoardTest { public static final int SIZE; public static final char PLAIN; public static final char SHADED; private char[][] board; public CheckerBoardTest() { ... } public void print() { ... } public static void main(String[] args) { new CheckerBoardTest().print(); } } There are three static variables: SIZE, PLAIN and SHADED. They are final so they act like constants. There is also one instance variable: board, a two dimensional array of characters. Besides these the class defines a constructor, an instance method, and the public static void method main that is needed to start the program. A class is a container. It can contain static members (variables and methods). The main method is a special static member the only one available to the java interpreter. In it this class instantiates itself (creates an object from the blueprint the class contains) and calls its print method. Very simple. Besides the use of final, for, arrays and the System.arraycopy(...) method the program doesn't have anything unusual in it so we move on to the next program. import java.io.*; public class CoinTossTest { static final String[] faces; public static void main(String[] args) throws IOException { } } The structure is even simpler here: one static (final) variable, and a main. These days the dialogue inside the main can be better implemented with a Scanner. The third program uses a class strictly as a container of static members. Three static methods are defined (four with main). main invokes the first and third, the first is self-contained, the third relies on a helper (second method: isPrime(...)). Dealing with exceptions is not as complicated as it may seem at first though. import java.io.*; public class PrimeFactorsTest { public static int readInt(String prompt) throws IOException { } public static boolean isPrime(int n) { } public static void printPrimeFactors(int n, int start) { } public static void main(String[] args) throws IOException { } } With the next program we use classes to model a situation: public class Card { public static final String[] FACES; public static final String[] SUITS; public static final int MAX_CARDS; protected int value; public Card() { ... } public Card(int n) { ... } public String getFace() { ... } public String getSuit() { ... } public String toString() { ... } } This models a Card. You see that where Cards are made constants FACES, SUITS, MAX_CARDS are defined. Each card has a value (which is protected; think of it as not public but not entirely private, it means that subclasses can access it) and can be created in one of two ways (two constructors). Each card, once created, can report itself through getString() which combines the two other accessors getFace() and getSuit(). Cards are organized in Decks, modeled as follows: import java.util.*; public class Deck { protected Stack cards; protected List drawnCards; protected Random random; public Deck(int size) { ... } public int getSize() { ... } public Card draw() { ... } public void shuffle() { ... } } This uses a Stack and a List inside to manage the deck. The code was written back in 2001 so there may be better ways to implement that now (parameterizable types). For example: http://www.cs.indiana.edu/classes/a202-dger/sum2009/0801.txt But the structure is clear: use Random to get random numbers, used in shuffle. getSize() is reporting on the size of the Deck, there is one constructor that creates a deck of a given size, shuffle shuffles and draw() returns a Card. Kind of straightforward. Finally the test creates and goes through an entire deck. Other than using Scanner for reading the code is up to date. However, when you compile it you get a warning. import java.io.*; public class CardTest { public static void main(String[] args) throws IOException { Deck deck = new Deck(52); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); for(int i = 0; i < 52; i++) { System.out.print("You drew the " + deck.draw()); reader.readLine(); } } } Next let's start modeling: public class Point1D extends Object { protected int x; public Point1D() { this(0); } public Point1D(int n) { setX(n); } public final int getX() { return x; } public final void setX(int n) { x = n; } public void translate(int dx) { x += dx; } public String toString() { return "Point1D [x=" + x + "]"; } } Number, Integer would be good numbers for this. Book calls it Vector (not best choice, I think, but not a bad one either). Interestingly enough there is a class Integer in java that does all of this and more. It's called a wrapper type, more on that later. So this is kind of interesting and simple at the same time. Objects of this type (note that we have no static members in there) are "holders" for integers that can translate. Now from this we can build Point2D: public class Point2D extends Point1D { protected int y; public Point2D() { this(0, 0); } public Point2D(int m, int n) { setX(m); setY(n); } public final int getY() { return y; } public final void setY(int n) { y = n; } public void translate(int dx, int dy) { x += dx; y += dy; } public String toString() { return "Point2D [x=" + x + ",y=" + y + "]"; } } This is just to illustrate the notion of inheritance (the class extension mechanism). Composition is another way of dealing with the same goals. When you read the code above think about the Point, Line, Triangle exercise in Homework Two (Line can be an extension of Point, but a Line could also be a pair of two Points; inheritance vs. composition). public class Point3D extends Point2D { protected int z; public Point3D() { this(0, 0, 0); } public Point3D(int m, int n, int o) { setX(m); setY(n); setZ(o); } public final int getZ() { return z; } public final void setZ(int n) { z = n; } public void translate(int dx, int dy, int dz) { x += dx; y += dy; z += dz; } public String toString() { return "Point3D [x=" + x + ",y=" + y + ",z=" + z + "]"; } } In Homework Two we can likewise say a Point is a pair of two ints, a Line is a Point with a destination, and a Triangle is a Line with a Point not on it (the third vertex). But we can also think of a Line being a pair of two Points and a Triangle being a triplet of Points. public class PointsTest extends Object { public static void main(String[] args) { System.out.println(new Point1D()); System.out.println(new Point1D(5)); System.out.println(new Point2D()); System.out.println(new Point2D(4, 9)); System.out.println(new Point3D()); System.out.println(new Point3D(-12, 25, 2)); } } Save these three classes in three files with names PointsTest.java, Point3D.java, Point2D.java and Point1D.java then compile and run PointsTest. If you wanted to store a bunch of Triangles, Circles, Rectangles in an array you can't. Unless they're all of the same type (Object, or maybe Shape). Suppose Triangles, Circles and Rectangles know how to calculate their areas. It follows if we want to store them in the array the type of the array should understand the need to calculate the own area. So a Shape should be asked to calculate (report) its area. But what is the formula for the area of a Shape (in general)? So if we have no general formula we need a placeholder in class Shape such that the area is calculated according to the type of Shape that object really is. This is called "dynamic method lookup" and here's an example of it in action: abstract class AbstractShape { public abstract double area(); public abstract double perimeter(); static double totalArea(final AbstractShape[] shapes) { double total = 0.0; for(int i = 0; i < shapes.length; i++) { total += shapes[i].area(); } return total; } static double totalPerimeter(final AbstractShape[] shapes) { double total = 0.0; for(int i = 0; i < shapes.length; i++) { total += shapes[i].perimeter(); } return total; } } class Circle extends AbstractShape { private double radius; public Circle(double r) { radius = r; } public double area() { return Math.PI * radius * radius; } public double perimeter() { return (2.0 * Math.PI * radius); } } class Rectangle extends AbstractShape { private double width; private double height; public Rectangle(double w, double h) { width = w; height = h; } public double area() { return (width * height); } public double perimeter() { return (2.0 * (width + height)); } } public class ShapeTest { public static void main(String[] args) { AbstractShape[] myShapes = { new Rectangle(10.0, 20.0), new Circle(5.5), new Rectangle(0.1, 0.2) }; System.out.println(AbstractShape.totalArea(myShapes)); System.out.println(AbstractShape.totalPerimeter(myShapes)); } } This not only illustrates what we discussed but it also exemplifies abstract classes. This example could have easily been worked out like this with interfaces (Shape an interface). To see this in action: a) put all the code in one file ShapeTest.java b) the name is supposed to be of the public class c) if there is no public class in a file the file can be called anything (but with extension .java) d) any number of non-public classes can be placed in a file e) compile the file and then run the class with main in it: javac ShapeTest.java, java ShapeTest The next example show how instance variables are shared among objects of a certain class. class IdObject { private static int uniqueId = 0; private int id; public IdObject() { id = uniqueId++; } public int getId() { return id; } public static int getNextUniqueId() { return uniqueId; } } public class IdTest { public static void main(String[] args) { IdObject[] objects = new IdObject[10]; for(int i = 0; i < 10; i++) { objects[i] = new IdObject(); System.out.println("id = " + objects[i].getId()); } System.out.println("Next id = " + IdObject.getNextUniqueId()); } } The code goes in IdTest.java which is compiled with javac. Then we run java IdTest to run the program. We close with two examples of existing tools in Java. It's instructive to clarify how they work. import java.util.*; public class SortTest extends Object { public static void main(String[] args) { Integer[] values = { new Integer(670), new Integer(90), new Integer(-23), new Integer(0), new Integer(2), new Integer(659), new Integer(1), new Integer(-40) }; Arrays.sort(values); for(int i = 0; i < values.length; i++) { System.out.println(values[i]); } } } Notice that "extends Object" is really not necessary. How does sort work? How would you sort an array of Rectangles, Circles and Triangles (by area)? Note: the answer is related but not immediate. It's presented below: import java.util.*; public class NameSortTest { public static void main(String[] args) { String[] strArray = { "Ward, Bill", "Osbourne, Ozzy", "Butlet, Geezer", "Iommi, Tony" }; System.out.println("String array before sort:"); for(int i = 0; i < strArray.length; i++) { System.out.println(i + ": " + strArray[i]); } Arrays.sort(strArray, new Comparator() { public int compare(Object a, Object b) { String s1 = (String)a; String s2 = (String)b; s1 = s1.substring(s1.indexOf(",")+1); s2 = s2.substring(s2.indexOf(",")+1); s1 = s1.trim(); s2 = s2.trim(); return s2.compareTo(s1); } } ); System.out.println("\nString array after sort:"); for(int i = 0; i < strArray.length; i++) { System.out.println(i + ": " + strArray[i]); } } } Note that compiling gives a warning. Here's another way of implementing this: import java.util.*; class Student implements Comparable { String name; double gpa; Student(String name, double gpa) { this.name = name; this.gpa = gpa; } public String toString() { return this.name + "(" + this.gpa + ")"; } public int compareTo(Student other) { if (this.gpa == other.gpa) { return this.name.compareTo(other.name); } else { if (this.gpa > other.gpa) return -1; else return 1; } } } class One { public static void main(String[] args) { ArrayList students = new ArrayList(); students.add(new Student("Thomas" , 2.1)); students.add(new Student("Paul" , 3.9)); students.add(new Student("Felicia", 2.5)); students.add(new Student("Jon" , 0.3)); students.add(new Student("Josh" , 1.1)); students.add(new Student("Molly" , 3.1)); students.add(new Student("Cecilia", 3.9)); students.add(new Student("Jamie" , 1.9)); students.add(new Student("Abe" , 0.3)); System.out.println( students + "\n----\n"); Collections.sort( students ); System.out.println( students + "\n----\n"); } } This method does not generate any warnings. It also does not use anonymous or inner classes. All of this just meant as a warmup.