Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parseInt method similar to parseDouble???

Status
Not open for further replies.

Ito2233

MIS
Sep 2, 2003
77
0
0
US
I'm trying to get values entered into a JTextField. I have heard of using "Double.parseDouble(variable_name.getText())" to change the string into a double. Is there an equivalent method for changing the string into an int?

Thanks
 
IE - Integer.parseInt()

Be warned though, if you try to convert a number which is a String such as "2.1" the above method will throw a NumberFormatException - you can only parse whole numbers. But if you do need to do this, then use :

int i = (int)Double.parseDouble("2.324");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top