Object: toString()
/*
* Output:
* Point[123456789,2147483647]
* */
class Point {
int x, y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
public String toString() {
return "Point[" + x + "," + y + "]";
}
}
public class MainClass {
public static void main(String args[]) {
Point p = new Point(123456789, 2147483647);
System.out.print(p);
}
}
Related examples in the same category