Skip to content

Instantly share code, notes, and snippets.

@ooharak
Created December 12, 2015 13:51
Show Gist options
  • Save ooharak/91da333adc8d1ea4bfbf to your computer and use it in GitHub Desktop.
Save ooharak/91da333adc8d1ea4bfbf to your computer and use it in GitHub Desktop.
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