How to create an IntStream from int array to check for match numbers in Java

1 Answer

0 votes
package javaapplication1;

import java.util.Arrays;
import java.util.stream.IntStream;

public class JavaApplication1 {

    public static void main(String[] args) {

        try {

            int[] arr = {1, 2, 3, 4, 5};
            
            IntStream stream = Arrays.stream(arr);
            
            boolean b = stream.anyMatch(n -> n >= 3);
            System.out.println(b);

        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}
 
/*
                   
run:
      
true
          
 */

 



answered Dec 16, 2016 by avibootz

Related questions

1 answer 180 views
1 answer 202 views
2 answers 145 views
1 answer 200 views
1 answer 176 views
176 views asked May 22, 2020 by avibootz
...