Using StringBuffer to Reverse String in Java

import java.util.Scanner;

public class Reverse {

 public static void main(String[] args) {
  Scanner input = new Scanner(System.in);
  System.out.print("ENTER STRING: ");
  StringBuffer reverse = new StringBuffer(input.nextLine()).reverse();
  System.out.println("REVERSED: " +reverse);
 }
}

Leave a Reply

Your email address will not be published. Required fields are marked *