import java.util.*;
public class Move {
public static String MoveX(String s, int n, String ans) {
if(s.length()==n){
return ans;
}
if (s.length()==n-1){
String sol = MoveX(s, n+1, ans + s.charAt(n));
return sol;
}
if(s.charAt(n) == βxβ){
String sol = MoveX(s, n+1, ans)+βxβ;
return sol;
}
else{
String sol = MoveX(s, n+1, ans + s.charAt(n));
return sol;
}
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int n = 0;
String ans = ββ;
System.out.println(MoveX(s, n, ans));
}
}
I wrote this code and I am getting the following errors
Exception in thread βmainβ java.lang.Error: Unresolved compilation problem:
Incompatible operand types char and String
at L1_25Jan.Move.MoveX(Move.java:12)
at L1_25Jan.Move.main(Move.java:26)