This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What parseInt() method do?

 
Ahmer Arman
Greenhorn
Posts: 6
  • 0
  • 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: 9059
12
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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