I am trying to write an app that will set a fixed array of a any size and then pass that into the method as a parameter.
package com.company;
public class NumberManipulation {
double [] array = {500,250,-350,124,87};
double minimum = Double.MIN_VALUE;
double maximum = Double.MAX_VALUE;
public void getMaximum() {
for (int i = 0; i < array.length; i++) {
if (array[i] > minimum) {
minimum = array[i];
}
}
System.out.println(minimum);
}
public void getMinimum() {
for (int i = 0; i < array.length ; i++) {
if (array[i] < maximum){
maximum = array[i];
}
}
System.out.println(maximum);
}
}
package com.company;
public class Main extends NumberManipulation {
public static void main(String[] args) {
NumberManipulation number = new NumberManipulation();
number.getMaximum();
number.getMinimum();
}
}
I know that I can set an array to a fixed amount via:
double [] array = new double [10] //if I wanted the array to be 10 indexes
I can't figure out how to pass that into the getMin and getMax methods, though.
Just for the record, I was able to solve to the problem on my own. The recommendation provided with the link was not adequate for the answer. Here is a link it (https://gist.github.com/BrianARuff/4c49aee1a5644fee35e80b2547e6c74d)