集册 Java实例教程 字符串反转

字符串反转

欢马劈雪     最近更新时间:2020-01-02 10:19:05

552
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
字符串反转


public class Main {

  public static void main(String args[]){

    String strOriginal = "Hello World";/**NowJava.com**/

    System.out.println("Original String : " + strOriginal);

    strOriginal = new StringBuffer(strOriginal).reverse().toString();

    System.out.println("Reversed String : " + strOriginal);

  }

}