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:
protected Set<MyClass> stuff = new HashSet<MyClass>();
I need to provide a public method that returns this set as a collection of objects of type "MyIfc".
public Collection<MyIfc> getMyStuff() {...}
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.
Collection<MyIfc> newstuff = stuff;
Any enlightenment is appreciated.