int[] smallest = {4,5,1,3,7};
System.out.println(getMinimum(smallest));
public static int getMinimum(int[] a){
    int min = a[0];
    for (int i = 0; i <a.length; i++){
        if(a[i] < min){
            min = a[i];
        }
    }
    return min;
}
This (above) works but this (below) doesn't:
int[] smallest = {4,5,1,3,7};
System.out.println(getMinimum(smallest));
public static int getMinimum(int[] a){
    int min = 0;
    for (int i = 0; i <a.length; i++){
        if(a[i] < min){
            min = a[i];
        }
    }
    return min;
}
I can't figure out why, in the top example getMinimum returns 1, but in the bottom example getMinimum returns 3? Both are doing the same thing yet one is wrong and the other right? Is it because I assigned min to equal 0?
 
     
     
     
    