Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What parseInt() method do?

 
Ahmer Arman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me regarding this method."parseInt(String str)" I cant understand how it works and what exceptions it can throw.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
int i = Integer.parseInt( "100" );

After this line of code, i = 100.
The method transforms a String to a primitive int.
 
Khurram Ajmeri
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please correct
int i=Integer.parseInt("100");
khurram
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic