Monday, 2 July 2012

program that display reverse string in java.

import java.io.*;
import java.util.*;
class Revs
{
   public static void main(String args[]) throws IOException
   {
     final String s;
     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
     s=br.readLine();
    final char[] word = s.toCharArray();
    final int l = s.length() - 2;
    final int ll = s.length() - 1;
    for (int i = 0; i < l; i++)
    {
        char x = word[i];
        word[i] = word[ll - i];
        word[ll - i] = x;
    }
System.out.println(s);
System.out.println();
System.out.println(new String(word));
   }
}