Create an instance of Point class from java.awt package - Java 2D Graphics

Java examples for 2D Graphics:Point

Description

Create an instance of Point class from java.awt package

Demo Code

import java.awt.Point;

public class Main {

    public static void main(String[] arguments) {
        Point location = new Point(4, 13);

        System.out.println("Starting location:");
        System.out.println("X equals " + location.x);
        System.out.println("Y equals " + location.y);

        System.out.println("\nMoving to (7, 6)");
        location.x = 7;/*from w ww .  ja v  a  2  s.c  om*/
        location.y = 6;

        System.out.println("\nEnding location:");
        System.out.println("X equals " + location.x);
        System.out.println("Y equals " + location.y);
    }
}

Related Tutorials