Java Swing Tutorial - Java Point.getX()








Syntax

Point.getX() has the following syntax.

public double getX()

Example

In the following code shows how to use Point.getX() method.

import java.awt.Point;
/*  w  w w. j  av a2  s.co m*/

public class Main {
  public static void main(String[] args) {
    Point p = new Point();
    
    p.setLocation(2.3D,3.3D);
    System.out.println(p.getX());
    System.out.println(p.getY());
  }
}

The code above generates the following result.