Sunday, January 1, 2012

Reverse the string in Java

Example



import java.io.*;
public class A11
{
public static void main(String args[])
throws IOException
{


String s="";
String s1="";
char ch;
int a;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
s=br.readLine();
a=s.length();
for(int i=a-1;i>=0;i--)
{
ch=s.charAt(i);
s1=s1+ch;

}
System.out.println("Length of String is::"+a);
System.out.println("Reverse of String::"+s1);


}

}

No comments:

Post a Comment