File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Question About Numberic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question About Numberic" Watch "Question About Numberic" New topic
Author

Question About Numberic

Yanxin Zhao
Ranch Hand

Joined: May 05, 2004
Posts: 65
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

Joined: Jul 02, 2002
Posts: 1865
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.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
How about
boolean Character.isDigit( char ch )
??
API


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
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

Joined: May 05, 2004
Posts: 65
thank you all, my problem has been finished under your help. thinks so much.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Yanxin, what did you end up doing?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question About Numberic