Java reverse words in a string
This is Java program to reverse words in a string. We use split method of the String class to break the complete sentence into the words.
For Example
Given string is: Java tutorial in ptutorial.
Result is: ptutorial in tutorial Java.
Java reverse words Example
public class SplitExample{ public static void main(String args[]){ String s1="Use of split method in java"; String[] str=s1.split("\\s"); int len=str.length; for(int i=len-1;i>=0;i--) System.out.println(str[i]); } }
Output
java in method split of Use
See Also
Form validation checking for all letters jquery
|
Java reverse string example
|
Xmlhttprequest method in ajax