Write a Java method onlyDigits that takes a string as aparameter. The method should remove from the string all characters,which are not digits, and return a string that contains onlydigits.
Expert Answer
Answer to Write a Java method onlyDigits that takes a string as a parameter. The method should remove from the string all characte…