Advertisement
DulcetAirman

max of vectors (3)

Aug 16th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ch.claude_martin;
  2.  
  3. import java.util.Arrays;
  4. import java.util.OptionalInt;
  5.  
  6. public class SomeClass {
  7.  
  8.   public static void main(String[] args) {
  9.     final int[] v1 = { 3, 5 };
  10.     final int[] v2 = { 3, 6 };
  11.     final int[] v3 = {};
  12.     final int[] v4 = { -1, Integer.MIN_VALUE };
  13.     long max = Long.MIN_VALUE;
  14.     int[] maxVec = null;
  15.     for (???????????) {
  16.       final OptionalInt m = Arrays.stream(v).max();
  17.       if (???????????) {
  18.         max = m.getAsInt();
  19.         maxVec = v;
  20.       }
  21.     }
  22.  
  23.     if (?????)
  24.       System.out.println(max + " -> " + Arrays.toString(maxVec));
  25.     else
  26.       System.out.println("No data");
  27.   }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement