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.

           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.

Popular posts from this blog

What is NBioBSP Java Library?

Draw arrow line example

Capture image from webcam java code, examples