Can a static method call itself in Java?

I have a static method that removes the ftp tree, so it must call itself recursively if it finds a subdirectory, can this cause confusion because it is static?

Edit: I did not test before my message, because if this causes a problem, I could delete additional files outside my test goal, I did not want to take risks.

+4
source share
5 answers

No, it is not, static methods can be used in recursive calls.

+7
source

no. why did you have a problem?

+2
source

No. are you okay. I probably have to write at least 30 characters for this post to be accepted.

+1
source

This will only be a problem if your recursive method does not have a good stop condition. You will quickly find out if this happens - you will get an OutOfMemoryError when the stop frames pile up each other.

+1
source

No, it will not :) I do not see the reasons why this will be a problem than with the instance method.

0
source

Source: https://habr.com/ru/post/1339587/


All Articles