Searching in a ArrayList with custom objects for certain strings

前端 未结 9 620
感情败类
感情败类 2020-12-01 02:09

I have a ArrayList with custom objects. I want to search inside this ArrayList for Strings.

The class for the objects look like this:

public class Da         


        
9条回答
  •  -上瘾入骨i
    2020-12-01 02:27

    contains() method just calls equals() on ArrayList elements, so you can overload your class's equals() based on the name class variable. Return true from equals() if name is equal to the matching String. Hope this helps.

提交回复
热议问题