Sunday, February 12, 2017

Java program to enter an string and reverse it

import java.io.Console;
class ReverseString2
{
public static void main(String[] args)
{
Console c=System.console();
String s=c.readLine("Enter String to reverse : ");
// StringBuffer sb=new StringBuffer(s);
StringBuilder sb=new StringBuilder(s);
System.out.println("Original String = "+sb);
System.out.println("Reversed String = "+sb.reverse());
}
}

Share this

0 Comment to "Java program to enter an string and reverse it"

Post a Comment