Todd O'Bryan wrote:
>public interface TreeNode {
> TreeNode getParent();
> List getChildren();
> Object getValue();
>}
>public class TypeATreeNode implements TreeNode {
> public TypeATreeNode getParent() {
> // code
> }
Your implementation of getParent() is returning a narrower type than the
interface's getParent(). So either you're not implementing a required
method, or the return-types are incompatible. I.e. not every TreeNode is a
TypeATreeNode.
Declare the implementations to return TreeNode.
>If so, why not?
Because the return-types won't match.
Read the sections in the Java Language Specification about return-types,
and also see the sections on implicit widening and non-implicit narrowing.
-- GG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden