What is the difference between set and list?
Answers were Sorted based on User's Feedback
Answer / janet
set stores elements in an unordered way but does not
contain duplicate elements,where as ist stores elements in
an ordered way but may contain duplicate elements.
| Is This Answer Correct ? | 200 Yes | 14 No |
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 |
Answer / may
set stores elements in an unordered way but does not
contain duplicate elements,where as it stores elements in
an ordered way but may contain duplicate elements.
| Is This Answer Correct ? | 37 Yes | 4 No |
Answer / krishnareddym. a
When we required uniqueness then we can use set and set
does not allow any duplications but list may contain
duplications set and list both extends collection interface...
| Is This Answer Correct ? | 22 Yes | 6 No |
Answer / vinod varma
set is an interface which doesnot allows the duplicate values
where as list is also an interface which allows the
duplicate values and we may not guarantee the order of
elements in set
but we can get the elements from list according to their
indexes. we may not insert the elements into set at the
specific index, but possible in list.
| Is This Answer Correct ? | 11 Yes | 2 No |
Why wait(),notify(),notifyAll() methods defined in Object class althought we are using in only threads.
Why are functions called methods in java?
What is the difference between super class & sub class?
How to create packages in java?
worst case complexities of Quick sort and Merge sort.
what is the diff b/w arraylist and vector?
6 Answers Code Genesis, Genesis, Sprintine Labs,
What is substring 1 in java?
How many bits is a double?
Under what conditions is an object’s finalize() method invoked by the garbage collector?
Can we write class inside a class in java?
What are the concepts of 'OOPS'?
Can multiple catch statements be used in exceptions ?