The method I am trying to write is by passing two arrays, one an array of integers and boolean array, then find the smallest, then next smallest, then next next smallest, etc values in the array "a". Outside of this method, the boolean at the corresponding index to smallest value will be changed to true if it was previously found to be smallest value in the array. All numbers get changed outside of this method except for the numbers set to true. Then method is repeated until every number has been selected.
The object smallest is only a means of returning the smallest value and index at the same time. Thoes are the only two instance variables and are only used in this method.
public Smallest indexOfSmallest(int[] a, boolean[] b){
Smallest x = new Smallest();
x.setSmallest(a[1]); // a[0] will always be 0
x.setIndex(1);
for(int i = 2; i<a.length;i++){
if(b[i] != true){
if(a[i] > 0 && a[i] < x.getSmallest()){
x.setSmallest(a[i]);
x.setIndex(i);
x.setSmallest(a[i]);
System.out.println(x.getIndex() + " - " + x.getSmallest());
}
}
}
return x;
}