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());
}
}
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());
}
}
0 Comment to "Java program to enter an string and reverse it"
Post a Comment