title: Java Arraylist of classes (custom data types), how to use contains
body: <p>in a simple ArrayList, I can use contains like this :</p>
  
  <pre><code>ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
  names.add("John");
  names.add("Peter");
  String find = "Peter";
  if (names.contains(find)) 
  System.out.println("I FOUND IT");
  </code></pre>
  
  <p>but how do I use contains (or something similar), if I have an ArraList of classes (custom data type)?</p>
  
  <pre><code>public class Person {
     public String name;
     public int age;
  
     public Person(String name, int age) {
      this.name= name;
      this.age= age;
  }
  
  public String getName() {
      return this.name;
  }
  public String getAge() {
      return this.age;
  }
  }
  ArrayList&lt;Person&gt; somePerson = new ArrayList&lt;Person&gt;();
  somePerson.add(new Person("John","25"));
  somePerson.add(new Person("Peter","84"));
  </code></pre>
  
  <p>How do I find in this ArrayList just the name "Peter", or just the score of "84"?
  I'm using loops and </p>
  
  <pre><code>if (somePerson.get(i).getName().contains(find))
  </code></pre>
  
  <p>but is there a way without loops, like in the simple ArrayList above?</p>