question: public static String stripNonDigits ( String str ) { StringBuffer result = new StringBuffer ( str . length ( ) ) ; for ( char candidate : str . toCharArray ( ) ) { if ( Character . isDigit ( candidate ) ) { result . append ( candidate ) ; } } return result . toString ( ) ; }
target:  Strips all non-digit characters from a string. The resulting string will only contain characters for which isDigit() returns true.