Java String Reverse

  • + 0 comments
                String A = sc.next();
        String revA = new String();
    
        for(int i=A.length(); i>0; i--){
            //revA += A.substring(i-1,i);
            revA = revA.concat(A.substring(i-1,i));
        }
    
        if(A.compareToIgnoreCase(revA) == 0){
            System.out.print("Yes");
        } else {
            System.out.print("No");
        }