Int And Integer?
Dear All..
I am a rookie of Java and i have a stupid problem..
Is there any defferent from
int a = 1;
and
Integer a =new Integer(2);
it makes me so confuse,can anyone explain for me ..
thanks a lot
Dear All..
I am a rookie of Java and i have a stupid problem..
Is there any defferent from
int a = 1;
and
Integer a =new Integer(2);
it makes me so confuse,can anyone explain for me ..
thanks a lot
int is a primitive, whereas Integer is a primitive wrapper, a true java object. Objects have constructors, methods and member variables, primitives do not. The diffrence is very significant, particularly as it pertains to operations you can perform on an object as opposed to a primitive data type.. I know this is brief and not quite complete but hopefully you get the point,, at least enough to investigate the differneces on yor own.