Demo class

public class Demo
{
    public static void main(String[] args)
    {
        Coordinate2D c1 = new Coordinate2D(5, 6);
        /* paused here */
        /* code not yet run */
    }
}

The Coordinate2D constructor finishes executing. The new keyword returns the memory address of the newly created object/instance.

The left side of assignment operator executes next. The code Coordinate2D c1 creates a variable of type Coordinate2D named c1.

The assignment operator (=) sets the value of c1 to the memory address of the newly created object.

Memory diagram

c1 pointing to a box containing x with value 5 and y with value 6

The memory address of the object is represented as an arrow. It is common to say that c1 refers/points to the object.

Parameters initX and initY no longer exist, since the constructor is no longer executing.

Forward to Step 4
Back to Step 2
Back to main example