GenuineSounds

See?!?!

Jun 3rd, 2014
385
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. package com.genuinevm.src;
  2.  
  3. import java.util.stream.IntStream;
  4.  
  5. public class Test {
  6.  
  7.     public static void main(String[] args) {
  8.         IntStream stream = IntStream.range(0, 64);
  9.         stream
  10.             // Filter takes type IntPredicate
  11.             // IntPredicate is a Functional Interface with a single function that takes type int and returns type boolean.
  12.             // So we can use type inference to simply pass in Test::something which takes an int and returns boolean.
  13.             .filter(Test::something)
  14.             .forEach(System.out::println);
  15.     }
  16.    
  17.     public static boolean something(int i) {
  18.         return i < 10;
  19.     }
  20. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment