File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Does a recursive function have to be static? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Does a recursive function have to be static?" Watch "Does a recursive function have to be static?" New topic
Author

Does a recursive function have to be static?

Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
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


-------<br />Thanks & regards,<br />anw
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
No, a recursive function (method, in Java) does not need to be declared static.


"I'm not back." - Bill Harding, Twister
Allen Williams
Ranch Hand

Joined: Sep 04, 2006
Posts: 136
Thanks!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Does a recursive function have to be static?
 
Similar Threads
An odd question...
public static void main()
recursive functions
Substring Challenge/Console input error
list the files or subdirectories ina directory