Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. List two important differences between lists andsets.________________________

ID: 3610798 • Letter: 1

Question

1. List two important differences between lists andsets.__________________________ ________________________________________________________ 2. ________T/F    SetmySet;    is a legal statement inJava. 3. ________T/F    Set mySet =new Set();         isa legal statement in Java. 4. What happens if you add a duplicate item to aSet?______________ 5. What method do sets use to findduplicates?____________________. 1. List two important differences between lists andsets.__________________________ ________________________________________________________ 2. ________T/F    SetmySet;    is a legal statement inJava. 3. ________T/F    Set mySet =new Set();         isa legal statement in Java. 4. What happens if you add a duplicate item to aSet?______________ 5. What method do sets use to findduplicates?____________________.

Explanation / Answer

Hi..         1) A Set is a collection with unique elements andprevents duplication within the collection. HashSet and TreeSet areimplementations of a Set interface.
   A List is a collection with an ordered sequence ofelements and may contain duplicates. ArrayList, LinkedList andVector are implementations of a List interface. 2)
Set mySet is the legal statement in Java    For Create a set called mySet then weuse                Set mySet = new HashSet(); 3)
Set mySet = new Set(); is not legal statement injava      To Create a set called mySet SetmySet = new HashSet(); 4)
     Set does not allow the duplicateelements 5)
   To eliminate duplicate values in a collection, Javaprovides it own API. HashSet   (java.util.*) is the classwhich implements Set interface I hope it is useful toyou. I hope it is useful toyou.