This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes parseInt() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "parseInt() method" Watch "parseInt() method" New topic

parseInt() method

ronak mehta

Joined: Aug 14, 2001
Posts: 23
int i=0;
char c='a';
is it possible
is i get integer value if yes then how? parseInt give integer value which is conveted in Integer object here am i right?
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Why donot you try these codes in your machine?It will help you to get used to these things.
Try this...

And also this...

And explain any errors you get, if any!
Answer the following:

  1. When does Integer.parseInt(String) throw an Exception?
  2. What Exception does it throw?

  3. Hope this helps,
    SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
    [This message has been edited by Desai Sandeep (edited August 30, 2001).]
Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
I guess white space does not format well as numbers.
Muhammad Farooq
Ranch Hand

Joined: May 08, 2001
Posts: 356
The method parseInt(Strings s) of the Integer class takes a String argument and adding " " with int(c) makes it a String that can be accepted as String and it throws NumberFormatException - if the string does not contain a parsable integer.

Muhammad Farooq<br />Sun Certified Programmer for Java 2 Platform<br />Oracle8i Certified Professional Database Administrator
I agree. Here's the link:
subject: parseInt() method
It's not a secret anymore!