How to find Max and Min value in array java.

Finding min or max value in premative array


Image


  import java.util.*;
  class cf
  {
    static Scanner input = new Scanner(System.in);
    public static void main(String[] args) {

          Integer[] arr = {2,3,1,5,3,61,12};
          int max = Collections.max(Arrays.asList(arr));
          int min = Collections.min(Arrays.asList(arr));
          System.out.println(max);
          System.out.println(min);

    }
  }

Output :

  61
  1

Popular Posts

java:17: error: local variables referenced from a lambda expression must be final or effectively final count ++ ;

Family Tree Project in Java

Creating basic tic tac toe android app using java