FileDocCategorySizeDatePackage
ToStringWith.javaAPI DocExample422Tue Feb 20 13:07:40 GMT 2001None

ToStringWith.java

/* Demonstrate toString() with an override */
public class ToStringWith {
	int x, y;

	/** Simple constructor */
	public ToStringWith(int anX, int aY) {
		x = anX; y = aY;
	}

	/** Override toString */
	public String toString() {
		return "ToStringWith[" + x + "," + y + "]";
	}
	/** Main just creates and prints an object */
	public static void main(String[] args) { 
		System.out.println(new ToStringWith(42, 86));
	}
}