Powered by Blogger.

How to Reverse a String (Sentence) in Java

>> Sunday, April 22, 2012

Reverse a String the form of words we are taking the help of StringTokenizer class it is having six featured methods in its class. We can use two of them. First apply StringTokenizer on the String then Split the sentence to words using delimiter. Then push all the words into Stack class. At last pop all words from Stack.

We can form a reverse sentence in this easy way as show below diagram.

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2014. All rights reserved.