 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Sun Nov 26, 2006 8:10 am Post subject: To determine whether the input is a string or INT? |
|
|
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
|
Posted: Sun Nov 26, 2006 8:10 am Post subject: Re: To determine whether the input is a string or INT? |
|
|
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
|
Posted: Mon Nov 27, 2006 4:15 am Post subject: Re: To determine whether the input is a string or INT? |
|
|
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 |
|
 |
|
|
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
|
|