Java stream reduce

This commit is contained in:
NKaushik89
2020-02-26 21:42:14 +05:30
parent e47c8e1a29
commit 9df71b8101
6 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
import java.util.List;
public class ExampleDiffAccumulatorCombiner {
public static void main(String[] args) {
List<String> numbers = Arrays.asList("one", "two", "three", "four", "five");
String result = numbers.stream().reduce("=>", (first, second) -> first + "$" + second, (first, second) -> first + "%" + second);
System.out.println(result);
}
}