Question: I am trying to write a java function that will count the number of ints in the string but I keep getting an error. here
I am trying to write a java function that will count the number of ints in the string but I keep getting an error.
here is my function.

Here is where I call it

This is my error:

76 Returns the number of tokens (as identified by the s.next) method on Scanners s) in the parameter sentence that are not an int, as identified by s.hasNextInt). For example, countTokensThatAreNotInt("this is 12 a test") should return 4, and countTokensThatAreNotInt("12" should return 0 78 79 80 81 82 83 84 85 86 87 IMPLEMENTATION NOTE:This will require a while loop. Use a Scanner to split the string into individual words. Use an if statement to figure out whether to count the token or not. *Replace this comment with your own Javados comment public static int countTokensThatAreNotInt(String sentence) 89 90 91 92 93 94 95 96 97 int nonInts-0; Scanner s = new Scanner(sentence); while (s.hasNextO&&(int) ch >= 48 ll (int) sh MethodCollection [Java Application] /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/bin/java (Jan countTokens found 5 on test input: This is a test 12 Exception in thread "main" java. lang.Error: Unresolved compilation problems: ch cannot be resolved to a variable ch cannot be resolved to a variable at a2.MethodCollection.countTokensThatAreNotInt (MethodCollection.java:91) at a2.MethodCollection.main(MethodCollection.java:45)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
