title: Java 8 filter for contains
body: <p>I am new to Java 8 and when I am trying to put a filter for all those cities which contains one letter. It doesn't work for me. However, when I run it with old approach it works.</p>
  
  <pre><code>    List&lt;String&gt; cityList = new ArrayList&lt;&gt;();
      cityList.add("Noida");
      cityList.add("Gurgaon");
      cityList.add("Denver");
      cityList.add("London");
      cityList.add("Utah");
      cityList.add("New Delhi");
  
      System.out.println(cityList);
  
  /* Prior to Java 8 Approach */      
      for (String city : cityList) {
              if(city.contains("a")){
                  System.out.println(city + " contains letter a");
              }
          }
  /* Java 8 Approach */           
      System.out.println(Stream.of(cityList).filter(str -&gt; str.contains("a")).collect(Collectors.toList()));
  </code></pre>
  
  <p>Here is the output</p>
  
  <pre><code>Noida contains letter a
  Gurgaon contains letter a
  Utah contains letter a
  []
  </code></pre>
  
  <p>Can you please explain me where am I am making mistakes.</p>
  
  <p>Thanks in advance !</p>