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

What are POJO classes in spring? What is the use of POJO Class, and How to create POJO classes.

How to create React project using command prompt?