Why is primitive type int changed to object Integer automatically when i put primitve type int to ArrayList in java?
autoboxing occurs as collections can only hold objects not primitives. If you need an int primitive out you will have to unbox it with intValue() method when you read it out.