Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Hello) We just save a lot of information in memory.
Who are "smart" I don't know)
Show me the code
In order to fix the overflow in your case, you need to create Lois and Pitter only once.
First of all change
Pitter husband = new Pitter();
on
Pitterhusband;
For Pitter do the same with Lois.
After that, you need to make sure that objects are created only once. For example, set properties from outside.
main() {
Pitter pitter = new Pitter();
Lois lois = new Lois();
pitter.setWife(lois);
lois setHusband(pitter);
}
In this case, the objects will be created only once and there will be no endless chain of creating new objects.
And stackoverflow works the same way in all languages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question