Differentiate between list and set.



Differentiate between list and set...

Answer / Tejveer Singh

List and Set are interfaces in Java that represent collections of elements. However, they have some differences:
1. Duplicate elements: A List can contain duplicate elements, while a Set cannot (unless it is a specific type like HashSet).
2. Ordered or unordered: A List maintains the order of its elements, while a Set does not.
3. Implementation: Lists implement the List interface and are implemented using various data structures like arrays, linked lists, and resizable arrays (ArrayList), while Sets implement the Set interface and are typically implemented as hash sets or tree sets.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What are the complexity of binary search?

1 Answers  


What is huffman’s algorithm?

1 Answers  


Why sorting is done?

1 Answers  


Can hashset contain duplicates?

1 Answers  


Can we use any class as map key?

1 Answers  


How to use appendNode() in linkedlist()?

1 Answers  


What is bubble sort used for?

1 Answers  


Explain the applications of stack?

1 Answers  


Can hashmap store null values?

1 Answers  


How to reference all the elements in a one-dimension array?

1 Answers  


Advanced problems related to Data Structures were asked

1 Answers   Motorola,


What happens when arraylist is full?

1 Answers  


Categories