0

I don't get it why it can't detect “+” symbol below this script please help.

public class Main {
    public static void main(String[] args) {
        String r_text = "10 + 10 + 10";
        
        String count = "";
        
        for (int i = 0; i < r_text.length(); i++){
            Object x = r_text.charAt(i);
            String c  = x.toString();
            
            if (c != "+"){
                System.out.println(c);
            }
        }
    }
}
Sanmay
  • 11

1 Answers1

0

This would be correct form:

public class Main {
    public static void main(String[] args) {
        String r_text = "10 + 10 + 10";
        
        String count = "";
        
        for (int i = 0; i < r_text.length(); i++){
            char x = r_text.charAt(i);
            if (x != '+'){
                System.out.println(x);
            }
        }
    }
}