When throwing exceptions, when Java Debug, some variables can be infinitely expanded, how to do it?
Let's start with an example of an error:
Exception in thread "main" Java.lang.StackOverflowError
At llj.mf.ace.c.<init> (c.java:3)
At llj.mf.ace.b.<init> (b.java:5)
At llj.mf.ace.c.<init> (c.java:5)
At llj.mf.ace.b.<init> (b.java:5)
At llj.mf.ace.c.<init> (c.java:5)
At llj.mf.ace.b.<init> (b.java:5)
At llj.mf.ace.c.<init> (c.java:5)
At llj.mf.ace.b.<init> (b.java:5)
....
....
Code for Error:
public class Ace {public static void main (string[] args) {new B ();}} public class B {c c = new C ();} public class C {b b = new B ();}
Cause of error: When you create a B object, the B object creates a C object, and the C object creates a B object ... This creates countless B objects, C objects, so it stackoverflowerror .
An example that can be infinitely expanded:
/** * This debug, there is an infinite number of subordinates (you have me, I have you) */public class BCBC {public static void main (string[] args) {b b = new B (); c C = new C (); B.C = c;c.b = b; System.out.println (B.equals (c)); Breakpoint at}static class B {c C;} Static Class C {b b;}}
The above example debugs:
This creates only a B object, a C object, and then references each other (pointing to the other's address). (I pointed at you, you pointed at me: B <------> C)
This explains why some variables can be expanded indefinitely when Java Debug is thrown.
Java at debug time, some variables can be expanded indefinitely (loop)?