• Post Reply Bookmark Topic Watch Topic
  • New Topic

No isNumber( )/isInteger( ) ?  RSS feed

 
Ayman Haboubi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot find an isNumber()/isInteger() method. Is there some other method in the java api that does the same number.
 
Petr Blahos
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. There are regular expressions in Java 1.4 in class String.
You can do e.g.:



(Or you can of course be much more precise.)
Integer.parseInt might help you too. If it throws
NumberFormatException it means that is wasn't an Integer.

Best regards,
Petr
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also, there's Character.isDigit()
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!