public class TestPrimitive {
    public static void main(String[] args) {
	IPrimitive i1 = new Primitive(1);
	IPrimitive i2 = new Primitive(true);

	IPrimitive[] p = {i1,i2};
	for (int i=0;i<p.length;i++)
	    System.out.println(p[i]);
	
	for (int i=0;i<p.length;i++) {
	    Object v = p[i].toObject();
	    if (v instanceof Integer) {
		int x = 1+ ((Integer) v).intValue();
		System.out.println(x);
	    }
	    else if (v instanceof Boolean) {
		boolean y = false & ((Boolean) v).booleanValue();
		System.out.println(y);
	    }
	}
    }
}

interface IPrimitive {
    String toString();
    Object toObject();
}

class Primitive implements IPrimitive {
    private Object v;
    public Primitive(int v) {this.v=new Integer(v);}
    public Primitive(boolean v) {this.v=new Boolean(v);}
    public String toString() { return v.toString(); }
    public Object toObject() { return v; }
}