1.

What is the difference between SET and LIST Interface?

Answer»

LIST is an ordered collection of elements and hence it maintains insertion order of elements while Set doesn't maintain any ORDERING of the elements. List allows DUPLICATE elements while Set doesn't allow any elements. List is index-based, i.e.we can access elements in List based on Index, whereas we can’t access Set using index. Concrete implementation of List INTERFACE are ArrayList, LinkedList, etc. Concrete implementation of Set implementations are HashSet, LinkedHashSet, TreeSet etc. we can insert any NUMBER of null values in List. But we can have only a single null value at most in Set. ListIterator can be used to traverse a List in both directions (forward and backward) however it cannot be used to traverse a Set. Using Iterator, we can traverse the elements in Set and List.



Discussion

No Comment Found