• Post Reply Bookmark Topic Watch Topic
  • New Topic

Does a recursive function have to be static?  RSS feed

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the web, I've seen examples of Java recursive functions that are declared static and seen examples where they weren't (don't know if these authors tried to compile and run the examples). I came across one reference that explicitly says that recursive functions must be static. A search for "recursive" on the Sun Java Tutorial web site turned up zero hits.

When I don't declare mine static, the compiler does not complain. Hence, the above question.

TIA
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, a recursive function (method, in Java) does not need to be declared static.
 
Allen Williams
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!