Java - Write code to reverse a string using StringBuffer

Requirements

Write code to reverse

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String s = "book2s.com";
        System.out.println(reverse(s));
    }/*  ww w  . ja v a2 s .  c  om*/

    public static String reverse(String s) {
        return new StringBuffer(s).reverse().toString();
    }
}

Related Exercise