[java]
public class StringReverse {
public static void main(String[] args) {
// 原始字符串(The First Method)
String str = "Hello World";
System.out.println("原始字符串: " + str);
System.out.print("反转后的字符串: ");
for (int i = str.length(); i > 0; i--) {
System.out.print(str.charAt(i - 1));
}
System.out.println("####################################");
// The Second Method
StringBuffer sb = new StringBuffer(str);
System.out.println("原始字符串: " + str);
System.out.print("反转后的字符串: ");
System.out.print(sb.reverse().toString());
}
}