listitemmethod (640B)
1 public static <T> ListItem<T> m(ListItem<T> l1, ListItem<T> l2) { 2 while (l1 != null && l2 != null) { 3 l1 = l1.next; 4 l2 = l2.next; 5 } 6 7 ListItem<T> head = null; 8 ListItem<T> tail = null; 9 10 while (l1 != null) { 11 if (head == null) { 12 head = tail = new ListItem<>(); 13 } 14 15 tail.key = l1.key; 16 17 if (l1.next != null) { 18 tail.next = new ListItem<>(); 19 tail = tail.next; 20 } 21 l1 = l1.next; 22 } 23 24 return head; 25 }