Move all occurrence of letter ' x ' from the string s to the end using Recursion | Java implementation to Move all occurrence of letter x from the string s to the end using Recursion ; Function to move all ' x ' in the end ; Store current character ; Check if current character is not ' x ' ; recursive function call ; Check if current character is ' x ' ; Driver code
import java . util . * ; class GFG { static void moveAtEnd ( String s , int i , int l ) { if ( i >= l ) return ; char curr = s . charAt ( i ) ; if ( curr != ' x ' ) System . out . print ( curr ) ; moveAtEnd ( s , i + 1 , l ) ; if ( curr == ' x ' ) System . out . print ( curr ) ; return ; } public static void main ( String args [ ] ) { String s = " geekxsforgexxeksxx " ; int l = s . length ( ) ; moveAtEnd ( s , 0 , l ) ; } }