unable to delete post
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
unable to delete post
Last edited by Pip_Squeak; April 2nd, 2014 at 09:27 AM.
I suspect your if statement bodies are not what you're thinking. Enclose the entire body of each if statement, and see if that helps. Like this:
if ( condition ) { // statement 1 // statement 2 // etc . . . }
Hi, thanks for your reply.
I'm still not any further forward i think I've just been staring at it too long
Post your updated code and describe the new results. Show an actual run, if possible, and describe how the actual outcome varies from what you expect or desire.
Focus on this block of code:
if (next.sibling!=null) next=next.sibling; next.sibling=member; if (current.name.compareToIgnoreCase(next.name) == 0) match = true; System.out.println("Name already exists");
The indentation used here is most likely misleading of the intention of the if blocks. The above, when braces are used consistently, is equivalent to
if (next.sibling!=null) { next=next.sibling; } next.sibling=member; if (current.name.compareToIgnoreCase(next.name) == 0) { match = true; } System.out.println("Name already exists");
Is this the logic that is intended here? E.g., next.sibling=member; is run regardless whether (next.sibling!=null) evaluates to true or false?
Thanks for your reply.
Yes, i believe so - it's just so i can have multiple siblings, rather than limit the structure to two kids (child & one sibling)