@Test public void explicitForLoop() { String result = StringExamples.formatArtists(SampleData.getThreeArtists()); assertEquals("[John Coltrane, John Lennon, The Beatles]", result); }
public static String formatArtists(List<Artist> artists) { String result = artists.stream() .map(Artist::getName) .collect(Collectors.joining(", ", "[", "]")); return result; }
StringExamples { public static String formatArtists(List<Artist> artists) { String result = artists.stream() .map(Artist::getName) .collect(Collectors.joining(", ", "[", "]")); return result; } }
StringExamples { public static String formatArtists(List<Artist> artists) { String result = artists.stream() .map(Artist::getName) .collect(Collectors.joining(", ", "[", "]")); return result; }  }
StringExamples { public static String formatArtists(List<Artist> artists) { String result = artists.stream() .map(Artist::getName) .collect(Collectors.joining(", ", "[", "]")); return result; }  static String formatArtists(List<Artist> artists); static String formatArtistsForLoop(List<Artist> artists); static String formatArtistsRefactor1(List<Artist> artists); static String formatArtistsRefactor2(List<Artist> artists); static String formatArtistsRefactor3(List<Artist> artists); static String formatArtistsRefactor4(List<Artist> artists); static String formatArtistsRefactor5(List<Artist> artists); static String formatArtistsReducing(List<Artist> artists); }
StringExamples { public static String formatArtists(List<Artist> artists) { String result = artists.stream() .map(Artist::getName) .collect(Collectors.joining(", ", "[", "]")); return result; }  static String formatArtists(List<Artist> artists); static String formatArtistsForLoop(List<Artist> artists); static String formatArtistsRefactor1(List<Artist> artists); static String formatArtistsRefactor2(List<Artist> artists); static String formatArtistsRefactor3(List<Artist> artists); static String formatArtistsRefactor4(List<Artist> artists); static String formatArtistsRefactor5(List<Artist> artists); static String formatArtistsReducing(List<Artist> artists);  }