What is the difference between set and list?

Answer Posted / sumit

set-->
when uniqueness is required you need to implement set.
e.g.
HashSet(unOrd,unSort) Fast access, assures no duplicates,
provides no ordering.
LinkedHashSet(Ord,unSort)No duplicates; iterates by
insertion order.
TreeSet(ascending,naturalord)No duplicates ; iterates in
sorted order.

list-->
when ordered list is required you need to implement list.
e.g.
ArrayList(Ord,unSort)Fast iteration and fast random access.
Vector(syncronized)
LinkedList()Good for adding elements to the ends, i.e.,
stacks and queues.

Is This Answer Correct ?    91 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are jee technologies?

520


Can interface be private in java?

533


Explain about features of local inner class?

579


How do you use compareto?

540


What is the use of generics? When was it added to the Java development Kit?

541






Is empty .java file name a valid source file name?

571


Can an integer be a string?

499


Why is string buffer better than string ?

582


What is space character in java?

556


Can a java program have 2 main methods?

533


What is the purpose of object oriented programming?

521


Is there is any difference between a scrollbar and a scrollpane?

550


Difference between static binding and dynamic binding?

549


What does exp mean in math?

520


Is arraylist zero based?

539