Set Interface

Set Interface -
      Set is very important when you want to collect unique elements. Set is follows the mathematical  fundamental of Set. Set Interface can contains one null value also. But some implementation classes are not allowed the null value.
    Set is not permitted two elements if both are equals. When any element is being added in set internally it check the element is already exist or not through equals and hashcode method. So Set override  equals and hashcode both method.
    Set has no extra method. It extends Collection interface. So all method of collection interface is in the Set. But set interface restrict the duplicate elements.
  
There are some classes which implements the Set Interface.
1.AbstractSet
2.ConcurrentSkipListSet
3.CopyOnWriteArraySet
4.EnumSet
5.HashSet
6.JobStateReasons
7.LinkedHashSet
8.TreeSet

           
           If you want to add any immutable element in the set interface. So behavior of set can be change if the value of the element is changed. If you want to add any ineligible element in set, it will through unchecked exception. So Such exceptions are marked as optional in the specification for this interface.

Comments

Recent Post

Recent Posts Widget

Popular posts from this blog

Capture image from webcam java code, examples

Use of req.query, req.params and req.body in NODE JS

How to capture finger prints in java