Move x at end problem

What’s wrong with my code.

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
String s = cin.nextLine();
System.out.println(endX(s));
}
}
public static String endX(String inputString){
xCounter = 0;
int writeIndex = 0;
final int size = inputString.length();
char [] resultArray = new char[size];
for(int i = 0;i<size;i++){
char c = inputString.charAt(readIndex);
if(c==‘x’){
xCounter++;
resultArray[size-xCounter] = c;
}else{
resultArray[writeIndex++] = c;
}
}
return new String(resultArray);
}
}

Initialise xCounter and readIndex…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.