Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: parseInt method

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default parseInt method

    what is the use of parseInt() method.?


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: parseInt method

    Back in the good old days before the Scanner class all input was in the form of Strings. If user needed to input a numerical value then your code would read the input as a String and parse it using the parseInt method. There are still many occasions when that method is useful but I can't be bothered to think of any.
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: parseInt method

    parseInt() method is used to convert String to the primitive int type.

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: parseInt method

    What better time than any to become acquainted with the java API docs. Presuming you are referring to the Integer class method, than:
    Integer (Java Platform SE 7 )

  5. #5
    Junior Member
    Join Date
    Oct 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: parseInt method

    Quote Originally Posted by copeg View Post
    What better time than any to become acquainted with the java API docs. Presuming you are referring to the Integer class method, than:
    Integer (Java Platform SE 7 )
    thanks sir now i find the use of parseInt.

  6. #6
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: parseInt method

    Quote Originally Posted by Junky View Post
    Back in the good old days before the Scanner class all input was in the form of Strings. If user needed to input a numerical value then your code would read the input as a String and parse it using the parseInt method. There are still many occasions when that method is useful but I can't be bothered to think of any.
    Reading user input from a JTextField would be an obvious one. JTextFields return Strings. You probably could wire a Scanner up to a JTextField somehow if you really wanted to, but that would be like killing a fly with a rocket launcher.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. Integer.parseInt problem
    By 3therk1ll in forum What's Wrong With My Code?
    Replies: 8
    Last Post: June 28th, 2013, 05:28 AM
  2. Interger.parseInt Question
    By Tedstriker in forum What's Wrong With My Code?
    Replies: 12
    Last Post: April 6th, 2013, 11:46 AM
  3. Replies: 1
    Last Post: January 23rd, 2013, 07:29 AM
  4. Use of Integer.parseInt
    By tarkal in forum Java SE APIs
    Replies: 3
    Last Post: September 8th, 2011, 03:37 AM
  5. Using Integer.parseInt
    By Fraz in forum Object Oriented Programming
    Replies: 1
    Last Post: April 5th, 2010, 07:50 AM