title: Whats the best to way convert a set of Java objects to another set of objects?
body: <p>Basic Java question here from a real newbie.  I have a set of Java objects (of class "MyClass") that implement a certain interface (Interface "MyIfc").  I have a set of these objects stored in a private variable in my class that is declared as follows:</p>
  
  <pre><code>protected Set&lt;MyClass&gt; stuff = new HashSet&lt;MyClass&gt;();
  </code></pre>
  
  <p>I need to provide a public method that returns this set as a collection of objects of type "MyIfc".</p>
  
  <pre><code>public Collection&lt;MyIfc&gt; getMyStuff() {...}
  </code></pre>
  
  <p>How do I do the conversion?  The following line gives me an error that it can't do the conversion.  I would have guessed the compiler knew that objects of class MyClass implemented MyIfc and therefore would have handled it.</p>
  
  <pre><code>Collection&lt;MyIfc&gt; newstuff = stuff;
  </code></pre>
  
  <p>Any enlightenment is appreciated.</p>