title: Fetch first element of stream matching the criteria
body: <p>How to get first element that matches a criteria in a stream? I've tried this but doesn't work</p>
  
  <pre><code>this.stops.stream().filter(Stop s-&gt; s.getStation().getName().equals(name));
  </code></pre>
  
  <p>That criteria is not working, the filter method is invoked in an other class than Stop.</p>
  
  <pre><code>public class Train {
  
  private final String name;
  private final SortedSet&lt;Stop&gt; stops;
  
  public Train(String name) {
      this.name = name;
      this.stops = new TreeSet&lt;Stop&gt;();
  }
  
  public void addStop(Stop stop) {
      this.stops.add(stop);
  }
  
  public Stop getFirstStation() {
      return this.getStops().first();
  }
  
  public Stop getLastStation() {
      return this.getStops().last();
  }
  
  public SortedSet&lt;Stop&gt; getStops() {
      return stops;
  }
  
  public SortedSet&lt;Stop&gt; getStopsAfter(String name) {
  
  
      // return this.stops.subSet(, toElement);
      return null;
  }
  }
  
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class Station {
  private final String name;
  private final List&lt;Stop&gt; stops;
  
  public Station(String name) {
      this.name = name;
      this.stops = new ArrayList&lt;Stop&gt;();
  
  }
  
  public String getName() {
      return name;
  }
  
  }
  </code></pre>