P20 { public static <T> Object[] removeAt_splitAt(List<T> list, int k) { Map<Boolean, List<T>> split = P17.split(list, k); List<T> first = split.get(true); List<T> second = split.get(false); T kth = first.remove(k - 1); first.addAll(second); return new Object[]{first, kth}; }  static Object[] removeAt(List<T> list, int k); static Object[] removeAt0(List<T> list, int k); static Object[] removeAt_splitAt(List<T> list, int k);  }
@Test public void shouldRemoveKthElementFromList_() throws Exception { Object[] result = P20.removeAt_splitAt(Arrays.asList("a", "b", "c", "d"), 2); assertThat(result[0], equalTo(Arrays.asList("a", "c", "d"))); assertThat(result[1], equalTo("b")); }