Lists { @NonNull public static <T> List<T> merged(@NonNull List<T> list1, @NonNull List<T> list2) { if (list1.isEmpty()) { return list2; } else if (list2.isEmpty()) { return list1; } else { final ArrayList<T> mergedList = new ArrayList<>(list1.size() + list2.size()); mergedList.addAll(list1); mergedList.addAll(list2); return mergedList; } } private  Lists(); @NonNull static List<T> merged(@NonNull List<T> list1, @NonNull List<T> list2); @NonNull static List<T> appended(@NonNull List<T> list, @NonNull T t);  }
@Test public void testMerged() throws Exception { final List<Integer> mergedList = Lists.merged(list, Arrays.asList(4, 5, 6)); assertThat(mergedList).isEqualTo(Arrays.asList(1, 2, 3, 4, 5, 6)); }