File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes What parseInt() method do? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What parseInt() method do?" Watch "What parseInt() method do?" New topic
Author

What parseInt() method do?

Ahmer Arman
Greenhorn

Joined: Nov 23, 2001
Posts: 6
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: 9053
    
  12
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
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
please correct
int i=Integer.parseInt("100");
khurram
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
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


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What parseInt() method do?