Point: equals(Object p) : Point « java.awt « Java by API






Point: equals(Object p)

 
/*
 * Output:
cPoint is located at: java.awt.Point[x=50,y=25]
aPoint is located at: java.awt.Point[x=0,y=0]
aPoint is now at: java.awt.Point[x=110,y=70]
aPoint and bPoint are at the same location.
 
 * */

import java.awt.Point;

public class MainClass {
  public static void main(String[] args) {
    Point aPoint = new Point();
    Point bPoint = new Point(50, 25);
    Point cPoint = new Point(bPoint);
    
    System.out.println("cPoint is located at: " + cPoint);
    
    System.out.println("aPoint is located at: " + aPoint);
    aPoint.move(100, 50);

    bPoint.x = 110;
    bPoint.y = 70;

    aPoint.translate(10, 20);
    System.out.println("aPoint is now at: " + aPoint);

    if (aPoint.equals(bPoint))
      System.out.println("aPoint and bPoint are at the same location.");
  }
}
           
         
  








Related examples in the same category

1.Point.x
2.Point.y
3.new Point(int x, int y)
4.new Point(Point p)
5.Point: move(int x, int y)
6.Point: translate(int dx, int dy)