Answered step by step
Verified Expert Solution
Link Copied!

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'.

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

4. Ignore small differences between scores.

Answered: 1 week ago

Question

Discuss communication challenges in a global environment.

Answered: 1 week ago