Finding the index number of the lowest value in an array

后端 未结 4 828
借酒劲吻你
借酒劲吻你 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:55

    You are assigning array value to the lowest, so change it as shown below:

    public static int leastRain (double[] mon4){
        int lowestIndex = 0;//set index as 0 instead of array value
        int lowestValue = mon4[0];
        for (int index=1; index

提交回复
热议问题