2

I tried to get the index of the smallest integer in an array with the following code, but indexOf returns -1.

package tutorial;

import java.util.Arrays;


public class Lists {

public static void main(String[] args){

    int[] stuff = {4,3,2,1,8,4};
    int minValue = Arrays.stream(stuff).min().getAsInt(); 
    System.out.println(minValue);
    int smallestIndex = Arrays.asList(stuff).indexOf(minValue);
    System.out.println(smallestIndex);
}

}  

0 Answers0