Results 1 to 2 of 2
- 04-19-2011, 04:31 PM #1Member
- Join Date
- Nov 2010
- Rep Power
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
- 04-19-2011, 04:32 PM #2
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.
- By Roselicious in forum New To JavaReplies: 3Last Post: 04-19-2010, 03:27 PM
- By H_P in forum Advanced JavaReplies: 1Last Post: 04-14-2010, 05:43 AM
- By Manfizy in forum New To JavaReplies: 2Last Post: 07-07-2009, 08:29 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 03-28-2008, 07:29 PM
- By ravian in forum New To JavaReplies: 3Last Post: 11-21-2007, 10:13 AM