(Java) Check array for increasing elements

前端 未结 5 1716
旧时难觅i
旧时难觅i 2021-01-03 13:48

I\'m attempting to create a method that checks an array for increasing elements. True should be returned if all the elements are in increasing order. I get an out-of-bounds

5条回答
  •  无人及你
    2021-01-03 14:14

    Because in a list with n items there are only n-1 gaps between them.

    Change to

    for (int i=0; i

    (Also you might want to check whether starting with false and setting to true is the right way around).

提交回复
热议问题