Repeat also traps?
I think it is, I found one today. If you can find it, continue to add it.
Since I officially wrote Java code this year, it is more and more amazed to Java's magic, and I don't say automatic garbage collection. Even her debugging is like a mysterious color (but, maybe my Java is too beautiful), A function in the actor can get the final return result of the function, then the debugger must have a similar analysis script (I use Eclipse 2.1.3). But this powerful function will sometimes help.
Come and see this ordinary code
Import java.util.Arraylist; import java.util.ITerator; import java.util.list;
/ * * ITeratRDebuggingtrap.java 2004-7-1 * * * chenxh * /
/ ** * @Author chenxh * 2004-7-1 * * * / public class iteratordebuggingTrap {
Public static void main (string [] args) {list list = new arraylist (); list.add ("a"); list.add ("b"); list.add ("c"); for (Iterator ITER = list.iterator (); ore.hasnext ();) {system.out.println (iter.next ());}}}
Results of the
ABC is not an abnormal, but if you are
System.out.println (iter.next ());
Plus the breakpoint, the tangible in the side is monitored,
Resulting
b
Very strange, isn't it. Careful observation is not difficult to find, in fact, the debugger itself also calls item.next (), and calls a multi-labeled NEXT (), the result is still related to the breakpoint, ie The number of monitors, if you are
Iterator it = list.iterator (); it.hasnext ();) {
Set the breakpoint, the result is back
c
If you take the code
List.add ("c");
Remove, it will be unfortunate to get a runtime error
Java.util.nosuchelementexception
But this is nothing to be very surprised, because I have already made the reason for the error, but I have just been very surprised.
Note: I use the IDE is Eclipse, my Java is limited, for some mainstream IDEs, such as JBuilder is not very familiar, I don't know if the tool like JBuider will also have such a small trap.