Question: The method ' justDigits' receives a string 's' as an argument. The method's job is to return a string consisting of only the digits in

The method 'justDigits' receives a string 's' as an argument. The method's job is to return a string consisting of only the digits in the string 's'.

The method 'justDigits' receives a string 's' as an argument. The method's

job is to return a string consisting of only the digits in

For example, if the string s is "012-234-5679", then the method returns the value "0122345679" Assume that the string s has at least one character in it and that you will use the static method of the Character class called isDigit to determine if a character represents a digit. Complete the method below by dragging and dropping code into the appropriate positions. public String justDigits (String s) StringBuilder sb for index = ; index if(Character.isDigit( (s.charAt(index)); s.length) s.charAt(index) 2 new StringBuilder(S) int return sb char (s.charAt (1)) null concat index+H new StringBuilder(O String sb.toString) new String(s) System.out.printin (sb) s.charAt(0) "012-234-5679" append "0122345679

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!