[Q#18828091][A#18828505] how to get the minimum,maximum value of an array?
https://stackoverflow.com/q/18828091
Here's my code. I need to get the minimum,maximum value of my array to be able for me get the range, whenever I input numbers the minimum value is 0. Please help me. Thank you:)
Answer
https://stackoverflow.com/a/18828505
Similarly find for the minimum value by changing lesser symbol.
APIzation
int[] convertedValues = new int[10];
int max = convertedValues[0];
for (int i = 1; i < convertedValues.length; i++) {
if (convertedValues[i] > max) {
max = convertedValues[i];
}
}
package com.stackoverflow.api;
public class Human18828505 {
public static int getMax(int[] convertedValues) {
int max = convertedValues[0];
for (int i = 1; i < convertedValues.length; i++) {
if (convertedValues[i] > max) {
max = convertedValues[i];
}
}
return max;
}
}
package com.stackoverflow.api;
/**
* how to get the minimum,maximum value of an array?
*
* @author APIzator
* @see <a href="https://stackoverflow.com/a/18828505">https://stackoverflow.com/a/18828505</a>
*/
public class APIzator18828505 {
public static void getValue(int[] convertedValues) throws Exception {
int max = convertedValues[0];
for (int i = 1; i < convertedValues.length; i++) {
if (convertedValues[i] > max) {
max = convertedValues[i];
}
}
}
}