This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Is there a quick way to check for a String containing numerics? Rather than going through each individual number (0 - 9) and seeing if it's contained within the String, I'd like to be able to return a true or false with one check for whether numerics are contained ot not. Thanks!
I assume that you want to know if the string contains any numbers, and not just (as assumed by the previous respondent) if it is a valid number. Java 1.4 will have a regular expression library in the platform (YES! ). In the mean time, you could use the one from the Apache project - Oro. However, if all you want is something quick and dirtyThis should do the job (haven't tested it though). Sufficiently fast for most purposes and just a single line of code. However, I would suggest leaving it in a method of its own as shown above as it functionality is not immediately obvious. - Peter