Revature interview question

What is the difference between a set and a map?

Interview Answers

Anonymous

10 Dec 2020

List allows duplicate elements. Any number of duplicate elements can be inserted into the list without affecting the same existing values and their indexes. Set doesn’t allow duplicates. Set and all of the classes which implements Set interface should have unique elements. Map stored the elements as key & value pair. Map doesn’t allow duplicate keys while it allows duplicate values.

11

Anonymous

31 Jul 2021

Both are used to store a collection of objects as a single unit. The main difference between a Set and a Map is that the set is unordered and contain different elements, whereas MAP contains the data in the key-value par.

1