Java 是否支持尾递归?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4401052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does Java support tail recursion?
提问by Donald Taylor
Possible Duplicate:
Why does the JVM still not support tail-call optimization?
可能的重复:
为什么 JVM 仍然不支持尾调用优化?
I see so many different answers online, so I thought I'd ask the experts.
我在网上看到很多不同的答案,所以我想我会问专家。
回答by Andrey
There is difference between tail recursion and tail recursion optimization. Tail recursion is supported by java because there is nothing special in it, tail recursion optimization is not supported.
尾递归和尾递归优化是有区别的。java支持尾递归是因为它没有什么特别之处,不支持尾递归优化。