Tutorialspoint

Program to reverse string in 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());
 }
}

Advertisements
Loading...