P03 { public static <T> T kthRecursive(final LinkedList<T> list, final int k) { if (k == 0) { return list.getFirst(); } return kthRecursive(new LinkedList<>(list.subList(1, list.size())), k - 1); }  static T kth(final List<T> list, final int k); static T kthRecursive(final LinkedList<T> list, final int k); static T kthStream(final List<T> list, final int k);  }
@Test public void shouldFindKthElementFromAListRecursive() throws Exception { LinkedList<Integer> numbers = linkedList(1, 2, 3, 4, 5); assertThat(P03.kthRecursive(numbers, 2), is(equalTo(3))); }