How do I remove an object from an ArrayList in Java?

后端 未结 9 1647
面向向阳花
面向向阳花 2020-12-15 01:06

I have an ArrayList that contains some object, such as User, and each object has a name and password property. How can I

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 01:27

    You could:

    • loop over the list with an iterator
    • check if each item in your list is the right user (checking the name)
    • if it is, use the remove method of the iterator.

提交回复
热议问题