What is the difference between Set and List in java

0 votes
What is the difference between a Set and a List?
Apr 26, 2018 in Java by Sushmita
• 6,920 points
63,350 views

2 answers to this question.

+1 vote

List is an ordered sequence of elements. User can easily access element present at specific index and can insert element easily at specified index.

Set is an unordered list of elements. Set does not have duplicate elements. 

If you need to know everything about Java and become a good Java programmer, it is suggested to join comprehensive Java certification course now.

answered Apr 26, 2018 by Akrati
• 3,190 points
0 votes
LIST SET
Duplicates YES NO
Order Ordered Depends on Implementation
Positional Access YES NO

List is an ordered sequence of elements whereas Set is a distinct list of elements which is unordered.

List <E>: 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<E>: 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.

answered Aug 14, 2019 by Sirajul
• 59,230 points

Related Questions In Java

0 votes
2 answers

What is the difference between Type List and type ArrayList in Java

By List, you actually tell, that your object ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
2,564 views
0 votes
2 answers

What is the difference between getAttribute() and getParameter() in java?

getParameter() returns http request parameters. Those passed from ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
22,537 views
0 votes
1 answer

What is the difference between getPath(), getAbsolutePath() and getCanonicalPath() in Java?

getPath() - returns a String which denotes the ...READ MORE

answered Jul 26, 2018 in Java by Mrunal
• 680 points
1,905 views
0 votes
2 answers

What is the difference between Map and HashMap in java?

The basic difference is : Map is ...READ MORE

answered Aug 28, 2019 in Java by Sirajul
• 59,230 points
29,480 views
0 votes
1 answer

what are the ways in which a list can be iterated

  There are 5 ways to iterate over ...READ MORE

answered Apr 23, 2018 in Java by sharth
• 3,370 points
1,098 views
+1 vote
3 answers

How to convert a List to an Array in Java?

Either: Foo[] array = list.toArray(new Foo[list.size()]); or: Foo[] array = ...READ MORE

answered Aug 7, 2018 in Java by Akrati
• 3,190 points
1,126 views
0 votes
2 answers

Java: convert List<String> to a String

With a java 8 collector, this can ...READ MORE

answered Aug 30, 2019 in Java by Sirajul
• 59,230 points
787 views
0 votes
1 answer

difference between lists and sets

There are a lot more differences such ...READ MORE

answered Jan 7, 2019 in Python by SDeb
• 13,300 points
810 views
0 votes
1 answer

What is the difference == and equals() in Java?

Both the answers (Syntaxes) are correct. If ...READ MORE

answered Jun 5, 2018 in Java by Akrati
• 3,190 points
979 views
0 votes
1 answer

What is the difference between jdk and jre?

JRE: It stands for Java Runtime Environment. ...READ MORE

answered Apr 20, 2018 in Java by Akrati
• 3,190 points
1,951 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP