最适合网络开发者的网站
Java 编程语言。初学者课程

尿素

Java How To Reverse a String


反转字符串

You can easily reverse a string of characters with the following example:

例子

String originalStr = "Hello";
String reversedStr = "";

for (int i = 0; i < originalStr.length(); i++) {
  reversedStr = originalStr.charAt(i) + reversedStr;
}

System.out.println("Reversed string: "+ reversedStr);
亲自尝试 »