Please help me regarding this method."parseInt(String str)" I cant understand how it works and what exceptions it can throw.
Ahmer Arman
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
int i = Integer.parseInt( "100" );
After this line of code, i = 100. The method transforms a String to a primitive int.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Khurram Ajmeri
Greenhorn
Joined: Nov 24, 2001
Posts: 6
posted
0
parseInt method converts string into integer if u wanna change "100" into integer u should use paeseInt() method. int i=parseInt("100"); parseInt method dont work with string like "Hello".
Khurram Ajmeri
Greenhorn
Joined: Nov 24, 2001
Posts: 6
posted
0
please correct int i=Integer.parseInt("100"); khurram
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
posted
0
If you use Integer.parseInt() to parse a String like "Hello" it will throw a NumberFormatException . HIH ------------------ Valentin Crettaz Sun Certified Programmer for Java 2 Platform