Reverse with StringBuilder

Lab Java Beginner 10 points

Read a line and print it reversed using StringBuilder.reverse().

Input

One line.

Output

The reversed line.

Example

Input

hello

Output

olleh
Sample input available Sample output available
Editor
Java

Hints

new StringBuilder(text).reverse() returns the builder reversed.

Solution explanation

StringBuilder is a mutable sequence of characters - ideal for building or editing text.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        System.out.println(new StringBuilder(line).reverse());
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD