Advertisement
DulcetAirman

max of vectors

Aug 16th, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement