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);
}
}