Question: Recall that Java's character class is the wrapper class for the primitive type char. The character class contains a static method called isDigit, which returns


Recall that Java's character class is the wrapper class for the primitive type char. The character class contains a static method called isDigit, which returns true exactly when its parameter is a digit, i.e., one of 0,1,2,..,8,9. Use the isDigit method to create a method called checkForDigit, which is passed a string as parameter and returns true if any digit 0,1,2,..,8,9 - is present in the string. Otherwise the method should return false. Example: "now is the time" -> false Example: "my name is r2d2" -> true Example: "I was number three"-> false Remember that because isDigit is static, you must specify the name of the class, and not an object, when you apply the method (e.g. Character.isDigit('a ). Hint: Your only job here is to fill in the test condition of the if statement. Java AP public boolean checkForDigit(String s) boolean b = false; for (int i = 0;-s.length(); i++.) 1 if b = true; break; end if )l/end for return b; //end method CHECK
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
