import java.io.Console;
class ReverseString
{
public static void main(String[] args)
{
Console c=System.console();
String s=c.readLine("Enter String to reverse : ");
String rev="";
for(int i=s.length()-1;i>=0;i--)
rev=rev+s.charAt(i);
System.out.println("Original String = "+s);
System.out.println("Reversed String = "+rev);
}
}
class ReverseString
{
public static void main(String[] args)
{
Console c=System.console();
String s=c.readLine("Enter String to reverse : ");
String rev="";
for(int i=s.length()-1;i>=0;i--)
rev=rev+s.charAt(i);
System.out.println("Original String = "+s);
System.out.println("Reversed String = "+rev);
}
}
0 Comment to "Java program to enter an string and reverse it."
Post a Comment