Sunday, 15 July 2012

Java ArrayList: Adding primitive type or its wrapper-class: What's the difference? -



Java ArrayList: Adding primitive type or its wrapper-class: What's the difference? -

imagine next arraylist in java:

arraylist<integer> u = new arraylist<integer>();

i want know if there difference when adding new values either primitive types or wrapper-classes:

u.add(new integer(12)); u.add(12);

thanks in advance!

when u.add(12); compiler rewrites u.add(integer.valueof(12)); more efficient u.add(new integer(12)); read more on official tutorial http://docs.oracle.com/javase/tutorial/java/data/autoboxing.html

java arraylist primitive

No comments:

Post a Comment