I am trying to count the amount of 'x' characters that are in a string, and print out the number. I end up just counting the number of characters in the string instead. Here is what I have tried:
int count = 0;
for (int j = 0; j < input1.length(); j++)
{
  char character = input1.charAt(j);
  count++;
}
if (indexX != -1)
  {
     System.out.println("x count: "+count);
  } // indexX = input1.indexOf('x');
 
     
     
     
    