in Java when we use parseInt(String) how can we chck that if the String has only the numbers, or it contains any character too. is there any sort of function or we have to chck every index separately ?
Cross posted at:
Printable View
in Java when we use parseInt(String) how can we chck that if the String has only the numbers, or it contains any character too. is there any sort of function or we have to chck every index separately ?
Cross posted at:
Use a regular expression - the matches() method of the String class does just that. For example, to check for integer values, use "[0-9]+" or "[\\d]+"
Lesson: Regular Expressions (The Java™ Tutorials > Essential Classes)