HiveBrain v1.2.0
Get Started
← Back to all entries
gotchajavaCritical

What is the difference between Set and List?

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
andbetweensetthedifferencelistwhat

Problem

What is the fundamental difference between the Set and List interfaces?

Solution

List is an ordered sequence of elements whereas Set is a distinct list of elements which is unordered (thank you, Quinn Taylor).

List:


An ordered collection (also known as a
sequence). The user of this interface
has precise control over where in the
list each element is inserted. The
user can access elements by their
integer index (position in the list),
and search for elements in the list.

Set:


A collection that contains no
duplicate elements. More formally,
sets contain no pair of elements e1
and e2 such that e1.equals(e2), and at
most one null element. As implied by
its name, this interface models the
mathematical set abstraction.

Context

Stack Overflow Q#1035008, score: 574

Revisions (0)

No revisions yet.