Created
December 12, 2015 13:51
-
-
Save ooharak/91da333adc8d1ea4bfbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class ArrayStreamExample { | |
public static void main(String[] args) { | |
int[] data = new int[] { 2, 4, 6, 9, 11 }; | |
String result = Arrays.stream(data).filter((e) -> (e % 2 == 0)) | |
.boxed() | |
.map(e -> String.format("<%d>", e)) | |
//.mapToObj(e -> String.format("<%d>", e)) | |
.reduce((l,r)->l+r) | |
.orElse("(empty)"); | |
System.out.println(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment