How to convert string to integer
Answers
Hey mate!!
here's your answer....
»To convert string into integer:
-»For this we need to convert the string into integer in one line code :
int i = Integer.parseInt(myString);
and of string represented by the variable in my string valid reason like "1”,"250" and so on ,it will be converted into JAVA inc .
•If it fails for some reason the conversion can throw a NumberFormatException, so your code should be a little bit longer to account for this.
››so, the Integer.parseInt(s.trim()) method is used to convert from the string s to the integer i in this line of code:
int i = Integer.parseInt(s.trim());
›and one more thing:
If you're interested in converting a String to an Integer object, use the valueOf() method of the Integer class instead of the parseInt() method.
★★Hope it will be helpful for you (^_^♪)★★