Integral to a Database Read
by in CodeSOD on 2025-06-05One of the key points of confusion for people unfamiliar with Java is the distinction between true object types, like Integer
, and "primitive" types, like int
. This is made worse by the collection types, like ArrayList
, which needs to hold a true object type, but can't hold a primitive. A generic ArrayList<Integer>
is valid, but ArrayList<int>
won't compile. Fortunately for everyone, Java automatically "boxes" types- at least since Java 5, way back in 2004- so integerList.add(5)
and int n = integerList.get(0)
will both work just fine.
Somebody should have told that to Alice's co-worker, who spends a lot of code to do some type gymnastics that they shouldn't have: