The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:Well, something on line 808 of file JTreeWithFTP.java is null.
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Campbell Ritchie wrote:So, node is null at this point. Or, there is something in the getUserObject() method which is null and causing an Exception. Since 808 appears to be the top line in your stack trace, the first explanation is probably correct and the second probably incorrect.
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Campbell Ritchie wrote:Start with line 807½See what that prints.
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Campbell Ritchie wrote:What’s this about null leaf nodes? Have you got any null leaf nodes?
Look at this treeBut that isn’t how a binary tree works at all. You don’t have different node and leaf classes. Your leaves are nodes which don’t have children, but they still have pointers to those children, so they will point to null.
That means: Every binary tree is guaranteed to contain null pointers. In fact, I think you can work out how many nulls there are: I think it is n + 1 where n is the number of nodes.
Now I know a displayed tree is rather different from a binary tree, but you need to checkDo your leaf nodes have null pointers to their supposed children? Similarly to their user Objects? Should you be returning null if you pick up one of those leaves, or should you throw an Exception, to be caught higher up the stack, or should you do something different? Have you set a user Object, or put one there by any other means?
And what happened when you printed my is not null test from earlier (line 807½)?
Not sure I can go much rather. Sorry, I have probably suggested all I can. You will have to look harder for that null.
Anybody else, please?
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Paul Clapham wrote:Come on, this isn't rocket science. Really. The simple solution is
The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Don't get me started about those stupid light bulbs. |