What happens if a set contains duplicate elements | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What happens if a set contains duplicate elements

14th Jun 2018, 7:06 AM
Saayiaravind S
Saayiaravind S - avatar
2 Answers
+ 6
Nothing will happen. It will ignore duplicate elements set.add(4); set.add(4); set.add(5); set.add(5); System.out.print(set); Output: [ 4,5]
14th Jun 2018, 12:29 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
0
Thanks a lot!
14th Jun 2018, 12:34 PM
Saayiaravind S
Saayiaravind S - avatar