Why are recursive methods usually static in Java?

前端 未结 1 1786
悲哀的现实
悲哀的现实 2021-02-06 18:12

I\'m reviewing recursion these days and found out that a lot of Java recursive method samples are static. Can somebody explain why?

My guess is that they want to save me

相关标签:
1条回答
  • 2021-02-06 18:36

    Because a recursive method/algorithm is generally controlled solely by its parameters and not by instance variables.

    Any method that does not rely on instance variables can (and probably should) be made static.

    0 讨论(0)
提交回复
热议问题