import java.math.BigInteger; import java.util.ArrayList; class MemoryCell { public MemoryCell( AnyType v ) { value = v; } public void setValue( AnyType v ) { value = v; } public AnyType getValue( ) { return value; } public String toString( ) { return "[MC " + value + "]"; } private AnyType value; } class Day22 { public static double totalArea( Shape [ ] arr ) { double total = 0.0; for( Shape s : arr ) total += s.getArea( ); return total; } public static double totalArea( ArrayList arr ) { double total = 0.0; for( Shape s : arr ) total += s.getArea( ); return total; } public static void main( String [ ] args ) { MemoryCell m1 = new MemoryCell( "hello" ); MemoryCell m2 = new MemoryCell( new BigInteger( "12345678901223345" ) ); Square [ ] arr2 = { new Square( 3 ), new Square( 2 ) }; ArrayList arr = new ArrayList( ); arr.add( new Square( 3 ) ); arr.add( new Square( 2 ) ); System.out.println( m1 ); System.out.println( m2 ); m1.setValue( "newvalue" ); String str = m1.getValue( ); System.out.println( str + " with length " + str.length( ) ); for( Shape s : arr ) System.out.println( s ); System.out.println( totalArea( arr ) ); System.out.println( totalArea( arr2 ) ); Object [ ] arr3 = new BigInteger[ 2 ]; arr3[ 0 ] = "hello"; System.out.println( arr3[ 0 ] ); } }