Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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'.
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 "0122345679Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started