Set Concept Simplified In Java

0
30
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

Set: Set is again a child interface of collection got introduced in Java-1.2V.

The Set interface extends to the Collection interface and it contains the methods that are inherited from Collection interface. The Set interface does not allow the use of duplicate elements in a collection.Hence the add() method returns false if we add the duplicate element to the collection.

If we want to represent a group of objects as a single entity where duplicates are not allowed and insertion order is not preserved, In such case we must implement Set .

The classes extending Sets are…

  • HashSet(C-1.2V)
  • LinkedHashSet(C-1.4V)

The Interfaces extends sets are…

  • SortedSet(I-1.2V)
  • NavigableSet(I-1.6V)
  • TreeSet(C-1.2V)

Set interface doesn’t contain any new methods and hence we have to use only collection interface methods.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

LEAVE A REPLY

Please enter your comment!
Please enter your name here