Is there a reason you revived a thread that hasn't been active in 6 years?
Also: congratulations in managing to write code that won't compile.
This won't compile. Can you guess why? Read More
I have already written code which does the same. Just wanted to find a better way to do it.So i could know where I could improve. This aint any school assignment either.
OK, thanks for clarifying that. I'm sure you can understand how it looked from your first post.
Anyway, your recursive method is cunning, but could be more understandably coded as a simple loop. You could also add the parsed-out words directly to a result String or StringBuilder without the need for the ArrayList. So I agree with stultuske, this could be a whole lot simpler.