public class ReverseString {
public static void main(String[] args) {
String str = "Hello World";
System.out.println("reverse of " + str + " is " +
Reverse(str));
}
static String Reverse(String str) {
StringBuffer tempString = new
StringBuffer(str.length());
for(int i = str.length()-1; i >= 0; i--)
tempString.append(str.charAt(i));
return(tempString.toString());
}
}
ReverseString.java output
reverse of Hello World is dlroW olleH
Tag: Study Code Program Java
No comments:
Post a Comment