public class PairOfObjects{ private Object first; private Object second; public PairOfObjects( Object first, Object second){ this.first = first; this.second = second; } public void setFirst( Object first ){ this.first = first; } public Object getFirst( ){ return first; } public void setSecond( Object second ){ this.second = second; } public Object getSecond( ){ return second; } @Override public String toString(){ return "PairOfObjects: " + first.toString() + ", " + second.toString(); } public static void main( String[] args ){ String myStr = new String( "Hello" ); Integer myInt = 42; Double myDouble = 3.141596; Character myChar = '1'; PairOfObjects strInt = new PairOfObjects( myStr, myInt ); String str = (String) strInt.getFirst(); System.out.println( "First: " + str ); System.out.println( strInt ); System.out.println(); PairOfObjects doubleChar = new PairOfObjects( myDouble, myChar ); Double d = (Double) doubleChar.getFirst(); System.out.println( "First: " + d ); System.out.println( doubleChar ); } }