/ Backend Development

How to reverse a String input in Java?

Creator Image
Bashar Alshaibani
15 Apr 2024 -
1 min Reading time
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        String n = input.nextLine();

        String output = new StringBuilder(n).reverse().toString();

        System.out.println(output);
    }

}