Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class rev_WbW {
- String st="";
- void input()
- {
- Scanner in=new Scanner(System.in);
- System.out.println("enter a sentence :");
- st=in.nextLine();
- }
- void rev()
- {
- String s2="";
- StringTokenizer s1 = new StringTokenizer(st," ");
- while (s1.hasMoreTokens())
- {
- /* Prints the elements from the String */
- s2=s1.nextElement()+" "+s2;
- }
- System.out.println(s2);
- }
- public static void main(String[] args) {
- rev_WbW ob=new rev_WbW();
- ob.input();
- ob.rev();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment