MAIN.JAVA:
import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println("Enter a string to reverse"); Scanner sc = new Scanner(System.in); String s = sc.nextLine(); StringBuilder sb = new StringBuilder(s); System.out.println("Reverse of the string is "+sb.reverse().toString()); } }