+ 1

Which is better approach Iterative or recursive while writing methods in Java?

E.g: Fibonacci series program can be written in iterative as well as in recursive way. Which approach has performance or any other benefits?

1st Sep 2017, 2:42 AM
shanky sharma
shanky sharma - avatar
2 ответов
+ 7
iteration loops to repeat lines of code and recursion is a function that calls itself to repeat
1st Sep 2017, 3:15 AM
P R
P R - avatar
+ 1
Here's the link which talks about performance impact of using recursion and iteration: https://stackoverflow.com/questions/2651112/is-recursion-ever-faster-than-looping
2nd Sep 2017, 4:43 PM
shanky sharma
shanky sharma - avatar