Why does my for loop check only the first element?

前端 未结 5 1271
心在旅途
心在旅途 2021-01-29 07:36

I have this method that checks the username and password of a user before login. Now my for loop checks only the first item, it finds that the first condition, u.getRole()

5条回答
  •  悲&欢浪女
    2021-01-29 08:16

    As has been pointed in the comments, you have only two alternatives in the loop, both make the loop to finish (on return or on break) Just take off the break; statement or change it for a continue;.

    By the way, why don't you select from User where role = 'recruiter' only? This will make the roundtrip to the database server not to return all users, but only the ones that you are interested in.

提交回复
热议问题