From 2635faa934974b1f57effbaeb770d49c2d06e5c9 Mon Sep 17 00:00:00 2001 From: Ulisses Lima Date: Thu, 20 Oct 2022 14:03:23 -0300 Subject: [PATCH] bael-5754 - quick fix * adapting code to the article --- .../com/baeldung/list/tostring/ListToStringUnitTest.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/tostring/ListToStringUnitTest.java b/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/tostring/ListToStringUnitTest.java index 479ccaf92f..92e85099fe 100644 --- a/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/tostring/ListToStringUnitTest.java +++ b/core-java-modules/core-java-collections-list-4/src/test/java/com/baeldung/list/tostring/ListToStringUnitTest.java @@ -27,15 +27,13 @@ class ListToStringUnitTest { List arraysAsList = Arrays.asList("ONE", "TWO", "THREE"); StringJoiner stringJoiner = new StringJoiner(","); - arraysAsList.stream() - .forEach(v -> stringJoiner.add(v)); + arraysAsList.forEach(stringJoiner::add); String commaSeparatedString = stringJoiner.toString(); assertThat(commaSeparatedString).isEqualTo("ONE,TWO,THREE"); StringJoiner stringJoinerWithDelimiterPrefixSuffix = new StringJoiner(",", "[", "]"); - arraysAsList.stream() - .forEach(v -> stringJoinerWithDelimiterPrefixSuffix.add(v)); + arraysAsList.forEach(stringJoinerWithDelimiterPrefixSuffix::add); String commaSeparatedStringWithDelimiterPrefixSuffix = stringJoinerWithDelimiterPrefixSuffix.toString(); assertThat(commaSeparatedStringWithDelimiterPrefixSuffix).isEqualTo("[ONE,TWO,THREE]");