public class IntVectorTest { public static void main( String[] args) { // Declaring arrays for IntVectors int[] array1 = { 1, 2, 3, 4}; int[] array2 = { 5, 6, 7, 8, 9, 10}; // Declaring new IntVectors IntVector vector1 = new IntVector( array1); IntVector vector2 = new IntVector( array2); // Print new IntVectors. System.out.println( "Vector 1: " + vector1); System.out.println( "Vector 2: " + vector2); System.out.println(); // Add vector2 to vector1 and print IntVectors again. vector1.add( vector2); System.out.println( "Vector 1: " + vector1); System.out.println( "Vector 2: " + vector2); System.out.println(); // Create two new IntVectors by using = operator and clone method. Then add a new element to vector2 to see the difference. IntVector vector3 = vector2; IntVector vector4 = vector2.clone(); vector2.addElement( 11); // Print these vectors System.out.println( "Vector 2: " + vector2); System.out.println( "Vector 3 (=): " + vector3); // Therefore we have created vector3 by using = operator, it refers to the same object with vector2. System.out.println( "Vector 4 (clone):" + vector4); // Therefore we have created vector4 by using clone method, it's a new object and it has an independent array from vector2. System.out.println(); // Declare a new IntVector with a null array IntVector vector5 = new IntVector(); // Try to print that IntVector System.out.println( "Vector 5: " + vector5); // Therefore, we've checked if array is null in our IntVector class methods. This line won't give any errors. // Try to add a new element and print vector5.addElement( 100); // Null check in class method again. Otherwise it will give an error. System.out.println( "Vector 5: " + vector5); } }