What is the difference between List and Set ?

Q. What is the difference between List and Set. 


Ans:-

s.No

List

Set

1.

List allow duplicates

Set does’t allow duplicates

2.

The List is an ordered collection which maintains the insertion order.

Whereas set is an unordered collection which does not preserve the insertion order.

3.

The List interface contains a single legacy class which is vector class

Where as set interface does not have any legacy class

4.

The List Interface can allow n number of null values

5.set Interface only allows a Single null value

Comments

Popular posts from this blog

How to create React project using command prompt?

How to achieve abstraction?

Interview Question? How to find square of each element in this Array {2,4,5,6,8} using map ?