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

3rd Apr 2020, 2:31 PM
Mohammad
1 Answer
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.
3rd Apr 2020, 7:04 PM
Jay W