The problem is in the blue code:
Originally posted by Farhan Tariq:
<pre>class outer1 { outer1 ou1 = new outer1(); outer1.inner1 in1 = ou1.new inner1(); class inner1{ int x = 100; } }</pre> |
This is recursive code: when you create an instance of outer1, you also create an instance variable ou1 that references a new instance of outer1 which in turn has its own instance variable ou1 that references a new instance of outer1 and so on until your stack blows up.
Remove "new outer1()" and
you should be fine.
If you need an outer1 to reference another outer1, do it in either a regular instance method or by assigning a parameter value passed to a constructor. Don't create a new outer1 instance in any code that is executed during instantiation which includes constructors and instance variable initialization.
Junilu
(rephrased)
[This message has been edited by JUNILU LACAR (edited May 25, 2001).]