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

How do you break a loop?

655


Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx

1712


What do you mean by mnemonics?

651


What is the use of pattern in java?

612


What is OOP Language?

721






What are streams in java 8?

644


What are different types of constants?

616


What are java packages? What is the significance of packages?

653


What is an immutable object?

667


What is java console application?

643


How will you get the platform dependent values like line separator, path separator, etc., ?

663


What is string [] java?

625


what is deadlock? : Java thread

615


What is a text string?

742


Can we have try without catch block?

745