P20 { public static <T> Object[] removeAt(List<T> list, int k) { List<T> input = new ArrayList<>(list); T kth = input.remove(k - 1); return new Object[]{input, 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(Arrays.asList("a", "b", "c", "d"), 2); assertThat(result[0], equalTo(Arrays.asList("a", "c", "d"))); assertThat(result[1], equalTo("b")); }