Ad
Code
Diff
  • //import java.util.Scanner;
    import java.lang.StringBuilder;
    
    public class Practice01{
    	public static String reverse(String input) {
    		/*Scanner sc = new Scanner(System.in);
    		System.out.println("Give the desired string to be reversed :");
    		String e = sc.nextLine();*/
        return new StringBuilder(input).reverse().toString();
    	}
    }
    
    • //import java.util.Scanner;
    • import java.lang.StringBuilder;
    • public class Practice01{
    • public static String reverse(String input) {
    • /*Scanner sc = new Scanner(System.in);
    • System.out.println("Give the desired string to be reversed :");
    • String e = sc.nextLine();*/
    • String result = "";
    • for(int i = input.length() - 1; i >= 0; i --){
    • result += input.substring(i , i + 1);
    • }
    • return result;
    • return new StringBuilder(input).reverse().toString();
    • }
    • }