title: Java Select element of list
body: <p>I'm stuck at a part when I have to create a list and select something in it.</p>
  
  <p>I have an executable</p>
  
  <pre><code>public class Executable{
      public static void main(String [] args){
          WeekEnd we = new WeekEnd();
  
          Personne pierre = new Personne("Pierrot");
          Personne anna = new Personne("anna");
  
          we.addPersonne(pierre);
          we.addPersonne(anna);
  
          System.out.println("test : "+we.findUsingEnhancedForLoop("anna"));
  
      }
  }
  </code></pre>
  
  <p>I have my class Personne</p>
  
  <pre><code>public class Personne{
      private String name;
  
      public Personne(String name){
      this.name=name;
      }
  
      public String getPersonne(){
      return this.name;
      }
  }
  </code></pre>
  
  <p>And my class WeekEnd where i try to select the name anna</p>
  
  <pre><code>import java.util.List;
  import java.util.ArrayList;
  
  public class WeekEnd{
      private ArrayList&lt;Personne&gt; listePersonne;
  
      public WeekEnd(){
        this.listePersonne = new ArrayList&lt;&gt;();
      }
  
     public Personne findUsingEnhancedForLoop(
     String name, ArrayList&lt;Personne&gt; listePersonne) {
  
        for (Personne personne : listePersonne) {
           if (personne.getPersonne().equals(name)) {
                return personne;
           }
       }
       return null;
     }
  
     public void addPersonne(Personne personne){
        listePersonne.add(personne);
     }
   }
  </code></pre>