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 |
What are the complexity of binary search?
What is huffman’s algorithm?
Why sorting is done?
Can hashset contain duplicates?
Can we use any class as map key?
How to use appendNode() in linkedlist()?
What is bubble sort used for?
Explain the applications of stack?
Can hashmap store null values?
How to reference all the elements in a one-dimension array?
Advanced problems related to Data Structures were asked
What happens when arraylist is full?