import java.util.Scanner;
public class StringReverse {
public static void stringReverse(String name)
{
String str=name;
char c[]=str.toCharArray();
System.out.println("Reversed String : ");
for(int i=str.length();i>0;i--)
{
System.out.print(c[i-1]);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("enter your string:");
String input=in.nextLine();
System.out.println("Given String Value :"+ input);
stringReverse(input);
}
}
OUTPUT:
enter your string:
Kanimozhi
Given String Value :Kanimozhi
Reversed String :
ihzominaK
public class StringReverse {
public static void stringReverse(String name)
{
String str=name;
char c[]=str.toCharArray();
System.out.println("Reversed String : ");
for(int i=str.length();i>0;i--)
{
System.out.print(c[i-1]);
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("enter your string:");
String input=in.nextLine();
System.out.println("Given String Value :"+ input);
stringReverse(input);
}
}
OUTPUT:
enter your string:
Kanimozhi
Given String Value :Kanimozhi
Reversed String :
ihzominaK
No comments:
Post a Comment
Please post your comments. Your comments make us to write more programs for you.