SHARE
TWEET

max of vectors

DulcetAirman Aug 16th, 2018 (edited) 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ch.claude_martin.foo;
  2.  
  3. import java.util.*;
  4. import java.util.stream.Stream;
  5.  
  6. public class SomeClass {
  7.     public static void main(String[] args) {
  8.         final int[] v1 = { 3, 5 };
  9.         final int[] v2 = { 3, 6 };
  10.         final OptionalInt max = Stream.of(v1, v2).flatMapToInt(Arrays::stream).max();
  11.         if (max.isPresent())
  12.             System.out.println(max.getAsInt());
  13.         else
  14.             System.out.println("No data");
  15.     }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top