Searching in a ArrayList with custom objects for certain strings

前端 未结 9 638
感情败类
感情败类 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条回答
  •  悲&欢浪女
    2020-12-01 02:16

    Probably something like:

    ArrayList myList = new ArrayList();
    //Fill up myList with your Data Points
    
    //Traversal
    for(DataPoint myPoint : myList) {
        if(myPoint.getName() != null && myPoint.getName().equals("Michael Hoffmann")) {
            //Process data do whatever you want
            System.out.println("Found it!");
         }
    }
    

提交回复
热议问题