How to create an DoubleStream from double array to check for match numbers in Java

1 Answer

0 votes
package javaapplication1;

import java.util.Arrays;
import java.util.stream.DoubleStream;

public class JavaApplication1 {

    public static void main(String[] args) {

        try {

            double[] arr = {1.14, 2.14, 3.14, 4.14, 5.14};
            
            DoubleStream stream = Arrays.stream(arr);
            
            boolean b = stream.anyMatch(n -> n >= 3.14);
            
            System.out.println(b);

        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}

/*
                   
run:
      
true
          
 */

 



answered Dec 16, 2016 by avibootz
...