Perfect reversible string | Java program to check if a string is perfect reversible or nor ; This function basically checks if string is palindrome or not ; iterate from left and right ; Driver Code
import java . io . * ; class GFG { static boolean isReversible ( String str ) { int i = 0 , j = str . length ( ) - 1 ; while ( i < j ) { if ( str . charAt ( i ) != str . charAt ( j ) ) return false ; i ++ ; j -- ; } return true ; } public static void main ( String [ ] args ) { String str = " aba " ; if ( isReversible ( str ) ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ; } }