import java.io.BufferedReader;
public class ReverseOfString {
public static String reverseString(String s)
{
int l = s.length();
String backward = "";
for (int i = l - 1; i >= 0; i--)
{
backward = backward + s.charAt(i);
}
return backward;
}
public static void main(String args[]) {
String backwards = reverseString("Umesh Kushwaha");
System.out.println("Reverse String is " + backwards);
}
}
Output:
Reverse String is ahawhsuK hsemU
public class ReverseOfString {
public static String reverseString(String s)
{
int l = s.length();
String backward = "";
for (int i = l - 1; i >= 0; i--)
{
backward = backward + s.charAt(i);
}
return backward;
}
public static void main(String args[]) {
String backwards = reverseString("Umesh Kushwaha");
System.out.println("Reverse String is " + backwards);
}
}
Output:
Reverse String is ahawhsuK hsemU
|
No comments:
Post a Comment