← BYTES
Java·Starter·Ref: 9.1.13

What is the difference in default duplicate-handling between an `ArrayList` and a `HashSet`?

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

a.Both reject duplicates automatically
b.ArrayList allows duplicate elements; HashSet does not (adding a duplicate is silently a no-op)
c.ArrayList cannot hold more than one element
d.HashSet preserves insertion order while ArrayList does not
List implementations like ArrayList allow the same value to appear multiple times; Set implementations like HashSet enforce uniqueness, silently ignoring an add() call for a value already present.

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#BYTES9113#Java