集册 Java实例教程 对象代表2的点类

对象代表2的点类

欢马劈雪     最近更新时间:2020-01-02 10:19:05

410
对象代表二维点的点类
/**N  o w  J a v a . c o m**/

class Point {

  private int x;

  private int y;


  public Point(int x, int y) {

    this.x = x;

    this.y = y;

  }


  // Re-implement toString() method of the Object class

  public String toString() {

    String str = "(" + x + ", " + y + ")";

    return str; 

  }

}