Coordinate2D class

The demonstrations on this page use the Coordinate2D class. There are no tricks in the Coordinate2D class. Each constructor and method does what its header suggests.

Selected parts of Coordinate2D are shown below.

A link to the complete class is below.

Object construction demo

public class Demo
    public static void main(String[] args)
        Coordinate2D c1 = new Coordinate2D(5, 6);

public class Coordinate2D
    private int x, y;

    // Other constructor not shown

    public Coordinate2D(int initX, int initY)
        x = initX;
        y = initY;

    // Additional methods not shown

See the step by step trace of this code.

The same trace is available with each step on its own page, starting with Step 1.

Additional classes & objects resources

Help & comments

Get help from AP CS Tutor Brandon Horn

Comment on Constructing objects