fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. private static int[] findMinMax(int arr[]) {
  11. int result[] = {Integer.MAX_VALUE, Integer.MIN_VALUE};
  12.  
  13. Arrays.stream(arr).forEach(num -> {
  14. result[0] = Math.min(num, result[0]);
  15. result[1] = Math.max(num, result[1]);
  16. }
  17. );
  18.  
  19. return result;
  20. }
  21.  
  22. public static void main (String[] args) throws java.lang.Exception
  23. {
  24. int t[] = {21, 5, 9, 133, 355, 11, 324, 758};
  25. int rng[] = findMinMax(t);
  26. System.out.println("Range: "+Arrays.toString(rng));
  27. }
  28. }
Success #stdin #stdout 0.13s 4386816KB
stdin
Standard input is empty
stdout
Range: [5, 758]