### Question:
Exercise4 { static <A> String join(final List<A> list, final String separator) { if (list.isEmpty()) return ""; else return Lists.foldLeft( Lists.tail(list), Lists.head(list).toString(), (joined, item) -> joined + separator + item ); }    }### Answer:
@Test public void shouldJoinAList() { final List<Boolean> list = asList(true, false, false, true); final String expected = "true:false:false:true"; final String actual = Exercise4.join(list, ":"); assertThat(actual, is(expected)); }
@Test public void shouldJoinAnEmptyList() { final List<Boolean> list = emptyList(); final String expected = ""; final String actual = Exercise4.join(list, "::"); assertThat(actual, is(expected)); }
@Test public void shouldJoinOneElementList() { final List<Integer> list = singletonList(1); final String expected = "1"; final String actual = Exercise4.join(list, "_"); assertThat(actual, is(expected)); }