← BYTES
Java·Starter·Ref: 9.1.10

What is the key difference between the primitive type `int` and the wrapper class `Integer`?

Have a question about this video? Mention reference 9.1.10 when you contact us.

a.There is no real difference
b.`Integer` can only hold negative numbers
c.`int` holds a raw numeric value directly; `Integer` is an object wrapping that value, usable where an object reference is required (e.g., in generic collections)
d.`int` is deprecated in modern Java
Primitives like `int` store their value directly and aren't objects at all; `Integer` wraps an int value inside an actual object, which is necessary anywhere Java requires a reference type -- most commonly, as the element type of a generic collection like `List<Integer>`, since generics can't be parameterized with primitives directly.

Find this on YouTube & Instagram

Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:

#BYTES#BYTES9110#Java