title: Java: Best way to store and access a list of objects
body: <p>What i want to do is store some instances of my class on a list and get a specific instance from that list.</p>
  
  <p>This is an example of a custom class </p>
  
  <pre><code>public class Person
  {
      private String name;
      //Several unrelevant fields here
  
      public Person(String name)
      {
          this.name = name;
      }
  
      public String getName()
      {
          return name;
      }
  
      //Several unrelevant methods here
  }
  </code></pre>
  
  <p>And this is the code i'm currently using to get one of the instances on the list, that is on the main class.</p>
  
  <pre><code>public class Main
  {
      private List&lt;Person&gt; people = new ArrayList&lt;Person&gt;();
      //More unrelevant fields here
  
      public Person getPerson(String name)
      {
          for (Person p : people)
              if (p.getName().equalsIgnoreCase(name))
                  return p;
          return null;
      }
      //More unrelevant methods here
  }
  </code></pre>
  
  <p>My question is if there's any other way to write this to increase the performance.</p>