我一直在工作,因爲昨天才得到這個函數的工作,但它不是。我已經嘗試了一切。我正在使用具有深度遞歸的函數。 我得到的輸出是很奇怪:功能無限遞歸的麻煩
Im going in with depth: 8
Depth in builder: 8
Depth in builder: 7
Depth in builder: 6
Depth in builder: 5
Depth in builder: 4
Depth in builder: 3
Depth in builder: 2
Depth in builder: 1
Depth in builder: 0
Depth in builder: 0
Depth in builder: 0
Depth in builder: 0
Depth in builder: 1
Depth in builder: 0
Depth in builder: 0
Depth in builder: 0
Depth in builder: 0
Depth in builder: 1
.....
,然後將它的1和0之間交替,直到永遠。這怎麼可能?這條線甚至不應該顯示,如果深度爲0.爲什麼這只是繼續前進?
如果你想知道,該節點的構造函數不會再次致電建設者。構造函數不會調用任何外部函數,現在它的方法就是從那裏來的。
的可能重複[爲什麼我的方法進入無限遞歸?(http://stackoverflow.com/questions/5332811/why-is-my-method進入無限遞歸) – interjay 2011-03-17 22:10:52