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 is the syntax and characteristics of a lambda expression? Explain

776


What is the use of System class?

834


What are the main uses of the super keyword?

745


Why do we need array in java?

724


What the difference is between execute, execute Query, execute Update?

564


What is the importance of hashcode() and equals() methods?

778


What is parseint?

717


explain copyonwritearraylist and when do we use copyonwritearraylist?

712


What is unicode with example?

798


What is the purpose of the strictfp keyword?

824


What is type parameter in java?

712


what is meant by HQL?

820


whar are the draw backs of programming lang step by step in Clang and next in C++ and next and in Java nad in .Net

1868


What does  mean in regex?

758


Difference between arraylist and hashset in java?

763