Java implementation of the approach
import java . io . * ; import java . util . * ; class GFG { static void reverse ( char A [ ] , int l , int h ) { if ( l < h ) { char ch = A [ l ] ; A [ l ] = A [ h ] ; A [ h ] = ch ; reverse ( A , l + 1 , h - 1 ) ; } }