Java examples for Object Oriented Design:Class
A Point Class Whose Object Represents a 2-D Point
class Point { private int x; private int y; public Point(int x, int y) { this.x = x;//from ww w . j a va 2 s . c om this.y = y; } // Re-implement toString() method of the Object class public String toString() { String str = "(" + x + ", " + y + ")"; return str; } }