Package com. he. list; public class Collections {public static ArrayList mergeList (ArrayList l1, ArrayList l2) {ArrayList l = new ArrayList (); int l1_length = l1.getLength (); int l2_length = l2.getLength (); int I = 0; int j = 0; while (I <l1_length & j <l2_length) {if (l1.get (I) <l2.get (j) {l. add (l1.get (I); I ++;} else {l. add (l2.get (j); j ++ ;}while (I <l1_length) {l. add (l1.get (I); I ++;} while (j <l2_length) {l. add (l2.get (j); j ++;} return l;} public static void main (String [] args) {ArrayList l1 = new ArrayList (); arrayList l2 = new ArrayList (); for (int I = 0; I <20; I ++) {if (I % 2 = 0) {l1.add (I );} elsel2.add (I);} System. out. println ("This Is List 1:"); for (int I = 0; I <l1.getLength (); I ++) {System. out. print (l1.get (I) + "");} System. out. println (); System. out. println ("This Is List 2:"); for (int I = 0; I <l2.getLength (); I ++) {System. out. print (l2.get (I) + "");} l1 = Collections. mergeList (l1, l2); System. out. println (); System. out. println ("merge two lists:"); for (int I = 0; I <l1.getLength (); I ++) {System. out. print (l1.get (I) + "");}}}For more information about ArrayList implementation, see the previous blog post.