class StoreSomething { A something; StoreSomething(A something) { this.something = something; } void set(A something) { this.something = something; } A get() { return something; } } public class Test { public static void main(String[] args) { StoreSomething a = new StoreSomething("I'm a string!"); StoreSomething b = new StoreSomething(17+4); b.set(9); int i = b.get(); String s = a.get(); } } class StoreString extends StoreSomething { StoreString(String something) { super(something); } } class StoreSomething2 extends StoreSomething { StoreSomething2(A something) { super(something); } void print() { System.out.println(""+something); } }