AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

To determine whether the input is a string or INT?

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sun Nov 26, 2006 8:10 am    Post subject: To determine whether the input is a string or INT? Reply with quote



Is there any function to determine whether the input is a string or
number?
let say i receive a string , the string may be holding a number such as
-1000 or it may be holding a word such as Good_moring, tele-phone and
etc.
Is there any function to determine whether the input is a string or
number?
Back to top
Andrew Thompson
Guest





PostPosted: Sun Nov 26, 2006 8:10 am    Post subject: Re: To determine whether the input is a string or INT? Reply with quote



saturnlee (AT) yahoo (DOT) com wrote:
....
Quote:
Is there any function to determine whether the input is a string or
number?

'try' it. E.G.

try {
int number = Integer.parseInt(input);
catch (NumberFormatException nfe) {
// don't bother dumping the trace, this is a string
parseInput( input );
}

HTH

Andrew T.
Back to top
Guest






PostPosted: Mon Nov 27, 2006 4:15 am    Post subject: Re: To determine whether the input is a string or INT? Reply with quote



Thanks, it works
saturnlee (AT) yahoo (DOT) com wrote:
Quote:
Is there any function to determine whether the input is a string or
number?
let say i receive a string , the string may be holding a number such as
-1000 or it may be holding a word such as Good_moring, tele-phone and
etc.
Is there any function to determine whether the input is a string or
number?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.