How to find the max element from an array list of objects?

前端 未结 5 653
小鲜肉
小鲜肉 2021-01-18 13:55

Collections.max(arraylist) doesn\'t work, and a regular for loop won\'t work either.

What I have is:

ArrayList

        
5条回答
  •  伪装坚强ぢ
    2021-01-18 14:38

    I have two ideas. First of all, you used forecast in the parameter, but it should be forecasts. Also, you never gave your code for the class Forecast. I may be wrong, because I didn't see all of your code, but you need to convert Forecast to a Integer. Do this by Integer i = Integer.parseInt(forecasts); Next use Collections.max(i)

提交回复
热议问题