String Reversal

 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());
    }
}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.