
A Program To Reverse Words In String in Java :-
For Example :-
Input:- Computer Software
Output :- Software Computer

import java.io.*;
class rev
{
public static void main(String args[])
{
try
{
int ki;
String k=new String();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String a=br.readLine();
ki=a.length();
for(int i=ki;i>0;i--)
{
k=k.concat(a.substring(i-1,i));
}
System.out.println(k);
}
catch(Exception e){}
}
}

class revstring { public static void main(String args[]) { try { int c=0; String sen=new String(); String word[]=new String[10]; System.out.println("enter a sentence"); BufferedReader br=newBufferedReader(newInputStreamReader(System.in)); sen=br.readLine(); word=sen.split(" ");
int i;
for(i=0;i<sen.length();i++)
{
if((sen.substring(i,i+1)).equals(" "))
{
c++;
}
}
for(int j=c;j>=0;j--)
System.out.print(word[j]+" ");
}
catch(Exception e){}
}
}