Sunday, February 12, 2017

WAP to enter an string and reverse it.

import java.io.Console;
class ReverseString3
{
public static void main(String[] args)
{
Console c=System.console();
String s=c.readLine("Enter String to reverse : ");
char[] rev=s.toCharArray();
System.out.println("Original String = "+s);
System.out.print("Reversed String = ");
for(int i=rev.length-1;i>=0;i--)
System.out.print(rev[i]);
}
}

Share this

0 Comment to "WAP to enter an string and reverse it."

Post a Comment