The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Use Integer.parseInt ( ) method

Posted by Kishori sharan on January 16, 2002 at 3:41 PM

Hi
Use parseInt method of Integer class to get int value from a string. similarly you have method Float.parseFloat() etc..


String str = "123" ; // Your int in string
try {
int value = Integer.parseInt ( str ) ;
}
catch ( NumberFormatException e ) {

// Error handling goes here
}

Thanks
Kishori



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us