Java程序用于反转字符串中的每个单词


Java程序用于反转字符串中的每个单词

import java.lang.*;

public class StringBufferDemo {

   public static void main(String[] args) {

      StringBuffer buff = new StringBuffer("tutorials point");

      System.out.println("buffer = " + buff);



      // reverse characters of the buffer and prints it

      System.out.println("reverse = " + buff.reverse());



      // reverse of the buffer is equivalent to the actual buffer

      buff = new StringBuffer("malyalam");

      System.out.println("buffer = " + buff);



      // reverse characters of the buffer and prints it

      System.out.println("reverse = " + buff.reverse());

   }

}