This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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: 9056
    
  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
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: What parseInt() method do?
 
It's not a secret anymore!