What is the difference between set and list?

Answers were Sorted based on User's Feedback



What is the difference between set and list?..

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

What is the difference between set and list?..

Answer / 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

What is the difference between set and list?..

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

What is the difference between set and list?..

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

What is the difference between set and list?..

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

Post New Answer

More Core Java Interview Questions

Highest level event class of the event-delegation model?

0 Answers  


Explain the use of volatile field modifier?

0 Answers  


what is mutability?which one is mutable String or StringBuffer?and why?give examples of each which shows the mutability of each String or StringBuffer

4 Answers   IBM, Zenon,


What is a java object and java application?

0 Answers  


Can we have more than one package statement in the source file?

0 Answers  






What is a singleton in genetics?

0 Answers  


What do negative exponents mean?

0 Answers  


Tell us something about set interface.

0 Answers  


What is the relationship between a method?s throws clause and the exceptions that can be thrown during the method?s execution?

2 Answers  


What is use of map in java?

0 Answers  


What releases of Java technology are currently available? What do they contain?

1 Answers  


What are File and RandomAccessFile classes?

2 Answers  


Categories