I have a string which only has numbers in it. I need to convert it to an integer. What is the best way to do it?
Ex. "5487" to 5487
http://www.tutorialspoint.com/java/number_parseint.htm
You can use Integer.praseInt() as follows.
Integer.praseInt()
int intValue = Integer.parseInt("45112");
If you need more clarification, please visit this link.
As like David said use Integer.parseInt() method to convert a string to and integer. For more details and practice programs on Integer please follow the link http://java.meritcampus.com/t/350/Integer--long
Wrapper class Integer which is static is used for converting string into integer. parseInt() method of Integer class is used.
int a=Integer.parseInt("12345");
For more Details Refer following link: java.meritcampus.com/t/264/Converting-numbers-to-and-from-strings?tc=mm209
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
http://www.tutorialspoint.com/java/number_parseint.htm
You can use
Integer.praseInt()
as follows.int intValue = Integer.parseInt("45112");
If you need more clarification, please visit this link.
As like David said use Integer.parseInt() method to convert a string to and integer. For more details and practice programs on Integer please follow the link http://java.meritcampus.com/t/350/Integer--long
Wrapper class Integer which is static is used for converting string into integer. parseInt() method of Integer class is used.
int a=Integer.parseInt("12345");
For more Details Refer following link:
java.meritcampus.com/t/264/Converting-numbers-to-and-from-strings?tc=mm209