title: "method stream() is undefined for the type Set<Person>"
body: <p>I'm trying to run an example java program I found in the java essential trails lessons.  I want to step through it using eclipse to better understand what's going on.  The Person class is fine with no errors but the MRTest class has one error at the end, that the stream() method is undefined for the type that's calling it.  I don't know how to fix this.</p>
  
  <pre><code>import java.util.List;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Comparator;
  import java.util.Collection;
  import java.util.function.Supplier;
  import java.util.Set;
  import java.util.HashSet;
  import java.time.chrono.IsoChronology;
  
  public class MRTest {
  
      // The method transferElements copies elements from one collection to
      // another
  
      public static &lt;T, SOURCE extends Collection&lt;T&gt;, DEST extends Collection&lt;T&gt;&gt;
          DEST transferElements(
              SOURCE sourceCollection,
              Supplier&lt;DEST&gt; collectionFactory) {
  
              DEST result = collectionFactory.get();
              for (T t : sourceCollection) {
                  result.add(t);
              }
              return result;
      }  
  
      public static void main(String... args) {
  
          List&lt;Person&gt; roster = Person.createRoster();        
  
          for (Person p : roster) {
              p.printPerson();
          }
  
  
          Person[] rosterAsArray = 
              roster.toArray(new Person[roster.size()]);
  
          class PersonAgeComparator
              implements Comparator&lt;Person&gt; {
              public int compare(Person a, Person b) {
                  return a.getBirthday().compareTo(b.getBirthday());
              }
          }
  
          // Without method reference
          Arrays.sort(rosterAsArray, new PersonAgeComparator());
  
          // With lambda expression
          Arrays.sort(rosterAsArray,
              (Person a, Person b) -&gt; {
                  return a.getBirthday().compareTo(b.getBirthday());
              }
          );
  
          // With method reference
          Arrays.sort(rosterAsArray, Person::compareByAge);
  
          // Reference to an instance method of a particular object
          class ComparisonProvider {
              public int compareByName(Person a,
                  Person b) {
                  return a.getName().compareTo(b.getName());
              }
  
              public int compareByAge(Person a,
                  Person b) {
                  return a.getBirthday().compareTo(b.getBirthday());
              }
          }
          ComparisonProvider myComparisonProvider = new ComparisonProvider();
          Arrays.sort(rosterAsArray, myComparisonProvider::compareByName);
  
          // Reference to an instance method
          // of an arbitrary object of a particular type
  
          String[] stringArray = { "Barbara", "James", "Mary", "John",
              "Patricia", "Robert", "Michael", "Linda" };
          Arrays.sort(stringArray, String::compareToIgnoreCase);
  
          Set&lt;Person&gt; rosterSetLambda =
              transferElements(roster, () -&gt; { return new HashSet&lt;&gt;(); });
  
          Set&lt;Person&gt; rosterSet = transferElements(
              roster, HashSet::new);
          System.out.println("Printing rosterSet:");
          rosterSet.stream().forEach(p -&gt; p.printPerson()); // This is the line that is the problem.
      }
  }
  </code></pre>