I'm relatively new to Java and I'm having a problem with a foreach loop in a method I'm writing. I keep getting an astronomical index out-of-bounds error but I have no idea where it's coming from.
Here's my code.
public static int smallestInt(int[] arr)
{
    int minVal = Integer.MAX_VALUE;
    
    
    for (int value : arr)
    {
        if (arr[value] < minVal)
        {
            minVal = arr[value];
        }
    }
    if (arr.length == 0)
    {
        return Integer.MIN_VALUE;
    }
    
    return minVal;
}
The error thrown states: Index 88 out of bounds for length 6
Any help will be appreciated, as I have been stuck on this for quite a while
 
     
    