I'm doing homework for a Data Structures class and making a 2-3 tree in NetBeans, but there's a glitch that keeps happening where a method is called twice, but the second time, it's being called by a statement that isn't there.
This is the method that is being called by the main class, main.Tree23.insert()
. It's line 33 in my Tree23 class.
Here is the call stack correctly listing the method calls so far:
But then, for no discernible reason, the method is called again and the line it calls is not even there. There's clearly blank space in line 51.
When I comment out the entire method, obviously, it doesn't run and I get a compilation error, and when I move it to another place in the code, it still runs line 51 (despite there being an entirely different statement there). I have no idea how to troubleshoot this. What could be causing this glitch?
I haven't used NetBeans a lot before, but I researched a bit for finding a proper solution. I think common sense debugging techniques should work, for example:
- Try copying your entire code in a fresh file and run it again, as some files are simply corrupted. Additional to this, you could run your code on a different editor; this way, you'll see if the problem occurs on NetBeans itself or if it is indeed a problem with your code.
- As the comment on your post said, you should also try cleaning and rebuilding your project. I haven't used this feature before, but as this post from Stack Overflow suggests: Netbeans 8.0.2 Clean and Build then Run results in old code being run, try going on BUILD and then CLEAN AND BUILD PROJECT (or use command "Shift + F11"). If this is not how it is displayed on your platform setup, try the way @markspace suggested, and I quote: <<Pick "Clean" from the menu at the top, then "Build" the entire project again.>>.
- Another thing that could cause the problem, although I doubt this is the root of the bug, is to check if the debugger is not causing misleading stack traces by checking its settings.
CREDITS TO @markspace for the second suggestion I offered in my answer.