import java.util.ArrayList;
import java.util.List;
public class Document {
private List <DocumentManager> DocumentElements= new ArrayList<DocumentManager>();
public void AddElement(DocumentManager d){
this.DocumentElements.add(d);
}
public DocumentManager getWidest(){
int top = 0;
DocumentManager toReturn;
for (DocumentManager d: DocumentElements){
if (d.getWidth() > top){
toReturn = d;
}
}
return toReturn;
}
}
We see that DocumentManager is the interface implemented, and in the Get Widest method, I'd like to return an Object that implements this interface (This can be a textbox, picture box, or a colorbox).
Upon trying to return a DocumentManager implementing Object (Here called toReturn), I encounter an error. Is there a way to do this?