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 internal implementation of set in java?

514


How do you create an array in java?

546


How can we access some class in another class in java?

557


What are locale settings?

558


What is fail first in java?

588






Is java an ide?

538


What interface is extended by awt event listeners?

605


Explain about complier design(phases)

637


Why do we use bufferedreader?

544


What is difference between an object and a class?

618


Which class is used by server applications to obtain a port and listen for client requests?

509


What is the purpose of encapsulation?

548


Is string is a keyword in java?

553


What is string english?

554


What is == in java?

578