Reverse a string

The problem

Write a program that prompts the user to enter a string and displays the string in reverse order.

Breaking it down

public static void main(String[] args) {

    Scanner input = new Scanner(;
    System.out.print("Enter a string: ");
    String s = input.nextLine();


    StringBuffer buffer = new StringBuffer(s);
    System.out.print(s + " in reverse is " + buffer.reverse());


Enter a string: A bugs life
A bugs life in reverse is efil sgub A