search in java ArrayList

前端 未结 8 1877
别跟我提以往
别跟我提以往 2020-12-03 05:04

I\'m trying to figure out the best way to search a customer in an ArrayList by its Id number. The code below is not working; the compiler tells me that I am mis

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 06:09

    You're missing the return statement because if your list size is 0, the for loop will never execute, thus the if will never run, and thus you will never return.

    Move the if statement out of the loop.

提交回复
热议问题