This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question About Numberic

 
Yanxin Zhao
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi: everyone
I want to konw that how to make sure a int number is numberic tpye? in other words, which method can return a boolean value if I input a numberic value ? I mean a method can judge whether a value is a numberic value or not.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to parse a String as an int value, then use the Integer.parseInt method. If it throws a NumberFormatException, then you know the String did not represent an int value.
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about
boolean Character.isDigit( char ch )
??
API
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's the best method if you are interested in testing a single char or testing the individual chars in a String.
 
Yanxin Zhao
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you all, my problem has been finished under your help. thinks so much.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yanxin, what did you end up doing?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic