### Question:
Exercise4 { static <A> A penultimate(final List<A> list) { if (list.isEmpty()) throw new IllegalArgumentException("list is empty"); if (list.size() == 1) throw new IllegalArgumentException("list has only one element"); return Lists.foldLeft( list, new Pair<>( Lists.head(list), Lists.head(Lists.tail(list)) ), (tuple, a) -> new Pair<>(tuple.getSecond(), a) ).getFirst(); }    }### Answer:
@Test public void shouldFindPenultimateElement() { final List<Integer> list = asList(1, 2, 3, 4); final Integer expected = 3; final Integer actual = Exercise4.penultimate(list); assertEquals(expected, actual); }