Results 1 to 2 of 2
  1. #1
    rajkobie is offline Member
    Join Date
    Nov 2010
    Rep Power

    Default What is the difference between Integer class and int primitive data type?

    I know what they are and how to construct each one of them. I don't understand what is the purpose of the Integer class. also, why do you use intValue ( ) to get the integer from an Integer object.

    I would appreciate if someone can distinguish between them :D

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power


    There are certain places where you have to use an Object, not a primitive. One example is adding an int to an ArrayList- you can't do that, so you wrap it in an Integer and add that instead.

    There are other things at play, but that's the gist.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. Primitive data type and class
    By Roselicious in forum New To Java
    Replies: 3
    Last Post: 04-19-2010, 03:27 PM
  2. JNI accessing non primitive data type
    By H_P in forum Advanced Java
    Replies: 1
    Last Post: 04-14-2010, 05:43 AM
  3. primitive Data types
    By Manfizy in forum New To Java
    Replies: 2
    Last Post: 07-07-2009, 08:29 PM
  4. Primitive data types of Java
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-28-2008, 07:29 PM
  5. Uisng primitive type values as keys for Hashtable
    By ravian in forum New To Java
    Replies: 3
    Last Post: 11-21-2007, 10:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts