1

I have a code that first receives an input from the user and then counts how many " ) " and " ( " there are in the input:

Scanner in = new Scanner(System.in);
String input = in.next();
String[] array = input.split("");
int countS = 0;
int countH = 0;
    for(int i = 0; i < input.length(); i++){
    if(array[i] == ")"){
        countH ++;
    }
    else if(array[i] == "("){
        countS ++;
    }
}
System.out.println(countH);
System.out.println(countS);

I what to know what's wrong with the program. All help is appreciated!

Dan
  • 175
  • 1
  • 1
  • 7

0 Answers0