Finding the index number of the lowest value in an array

后端 未结 4 836
借酒劲吻你
借酒劲吻你 2021-01-21 22:32

I have to return the index number of the lowest value in an array of 12 numbers. I keep getting 12 as the result every time I run it. Here is my code:

minRain =          


        
4条回答
  •  情话喂你
    2021-01-21 22:53

    It is a silly mistake you made - you assigned index to your variable instead of an array value. Do this:

    public static int leastRain (double[] mon4){
        int lowest = 0;
    
        for (int index=1; index

提交回复
热议问题