I am supposed to write recursive program. I have done this below, however I don't know if my understanding of recursion is correct. I believe that it is a method which calls this method inside. In my case (insertCommas).
Related Article:Java Recursion Help
is a solved Java discussion thread by MrHardRock that has 8 replies, was last updated 1 year ago and has been tagged with the keywords: common, denominator, greatest, java, recursion.
The most common type of recursion is what we call "tail recursion" - a function directly calling itself, which is what you are doing here. There is indirect recursion where a function A calls function B, which somewhere down the line agains calls to function A.
So, yes your FUNCTION is recursive. A recursive program is something else entirely... :-)
As rubberman said, yes it is recursive. If you ask whether it is correct, I would say no. Have you tested it? If a string "1234" goes in, what would be your result? If a string "1234567890123" goes in, what would be your result?