0
Required: Variable - Found: Value (Java)
Error: "Required: Variable - Found: Value" How can I correct it? public static void main(String[] args) { Scanner sc = new Scanner(System.in); String e = sc.next(); int l = e.length(); for(int i = 0; i < l; i++) { if(e.charAt(i) != '(' || e.charAt(i) != ')') >>>> e.charAt(i) = ''; <<<< (Error!!!) } char[] exp = e.toCharArray(); }
1 Antwort
0
String is immutable meaning you can't modify it's characters. What you are trying to do at e.charAt(i)=''; is assign a value to it. You will need to create a new string.