L
L
LaYof2016-07-08 12:26:43
Java
LaYof, 2016-07-08 12:26:43

How does stackoverflow work in java in general?

Can't fix stack overflow. How do smart and educated people solve this problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
programmerjava, 2016-07-08
@programmerjava

Hello) We just save a lot of information in memory.
Who are "smart" I don't know)
Show me the code

V
void_phoenix, 2016-07-08
@void_phoenix

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 question

Ask a Question

731 491 924 answers to any question