Blogger

Delete comment from: Javarevisited

Nice One - One more operation is Reversing the words of Palindrome Sentences.

String str = "India is Great becuase Great is India";

public String reverseWords(String str) {
String arr[]=str.split(" ");
StringBuilder stb=new StringBuilder();
for(int i=arr.length-1;i>=0;i--)
stb.append(arr[i]+" ");
return stb.toString();
}

Chandraprakash Sarathe
---------------------------
http://javaved.blogspot.com/

Feb 2, 2012, 6:10:14 AM


Posted to How to Reverse String in Java Using Iteration and Recursion - Example

Google apps
Main menu