Basically, you can use Integer.parseInt function to convert the string into numbers, but we need to take care of NumberFormatException.
String myString = "1234";
int foo = Integer.parseInt(myString);
It will looks like this:
foo = Integer.parseInt(myString);
catch (NumberFormatException e)
foo = 0;
I hope this will help.
Want to become a Java expert? join Java Training now!!
Want to know more about Java? Watch this video on Java Tutorial for Beginners | Java programming: