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?
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 :
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.