-
July 10th, 2014, 09:06 AM
#1
subclassing in java
I have defined a subclass of DefaultMutableTreeNode Class in java :
public AccountsTreeNode extends DefaultMutableTreeNode {
}
in this class I have a recursive method called getsorted(ArrayList list_) , which accummulated the list_.
In this method, I have to call this.children() which returns the children of the node, but the children
are all of type "DefaultMutableTreeNode". I have to call the method getsorted on these children,
but since the getsorted is a mehtod of AccontsTreeNode, it gives me runtime cast error.
What is the best solution to these problem? Should I convert children to AccountTreeNode type by
overriding the children() method?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|