whats the difference with and reserved word int and Integer class?
Integer[] number = new Integer[12];
and
int[] numbers = new int[12];
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.
whats the difference with and reserved word int and Integer class?
Integer[] number = new Integer[12];
and
int[] numbers = new int[12];
int is a primitive, Integer is an immutable class. In most cases you want to stick with using primitives. In certain cases, say cases in which Objects are needed to do something, you need to use the object form (an example would be using it in Collections - although as of 1.5 the compiler does the conversions for you).
see int vs Integer : Java Glossary
chronoz13 (December 29th, 2009)
that helped me bit sir! thats why im having problems with int[] arrays,,
Integers allows null values, while int doesnt, the offset or default value of int is '0' , which has no countable value but nut null...
0 is definitely a value
If you wish to 'nulify' an int, you can initialize the value to something you know it will never be (in many cases this can be Integer.MAX_VALUE or Integer.MIN_VALUE) - which is sort of a pseudo-null in the sense that if it is equal to this default value, its value was never set.
chronoz13 (December 31st, 2009), DanielJamesCollier (July 3rd, 2012)
yah exactly world! thats why im having problems with int arrays!! because of 0, and 0 != null