Two ArrayLists a1 and a2 are created and initialized with strings. a1 contains 5 strings and a2 contains 3 strings that overlap with a1. The code compares the sizes of a1 and a2, and if a1 is larger it prints the remaining elements of a1 after the overlapping elements, otherwise it prints the remaining elements of a2.
Two ArrayLists a1 and a2 are created and initialized with strings. a1 contains 5 strings and a2 contains 3 strings that overlap with a1. The code compares the sizes of a1 and a2, and if a1 is larger it prints the remaining elements of a1 after the overlapping elements, otherwise it prints the remaining elements of a2.
Two ArrayLists a1 and a2 are created and initialized with strings. a1 contains 5 strings and a2 contains 3 strings that overlap with a1. The code compares the sizes of a1 and a2, and if a1 is larger it prints the remaining elements of a1 after the overlapping elements, otherwise it prints the remaining elements of a2.
{ int k = 0; for (int i = 0; i < a2.size(); i++) { if (!((String)a1.get(i)).equals((String)a2.get(i))) { System.out.println((String)a2.get(i)); } k = i; } k++; for (int i = k; i < a1.size(); i++) { System.out.println((String)a1.get(i)); } } else { int k = 0; for (int i = 0; i < a1.size(); i++) { if (!((String)a1.get(i)).equals((String)a2.get(i))) { System.out.println((String)a2.get(i)); } k = i; } k++; for (int i = k; i < a2.size(); i++) { System.out.println((String)a2.get(i)); } }