Answers for "how to get max value from array java"

1

java max array

public static String max(String[] arr) {
  String result = arr[0];
  for (int i = 1; i < arr.length; ++i) {
    if (result.compareTo(arr[i]) < 0) result = arr[i];
  }
  return result;
}
Posted by: Guest on February-05-2021
0

java max array

public static double max(double[] arr) {
  double result = Double.NEGATIVE_INFINITY;
  for (int i = 0; i < arr.length; ++i) {
    if (result < arr[i]) result = arr[i];
  }
  return result;
}
Posted by: Guest on February-05-2021

Code answers related to "how to get max value from array java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language