Previously we have discussed about
Here we learn What is Set interface in Java.But Before That you must Know What is Collection Interface in Java ?
Interface Set<E>
Type Parameters:
E - the type of elements maintained by this set
All Superinterfaces:
Collection<E>, Iterable<E>
All Known Subinterfaces:
NavigableSet<E>, SortedSet<E>
All Known Implementing Classes:
HashSet, LinkedHashSet, TreeSet, AbstractSet, EnumSet, ConcurrentSkipListSet, CopyOnWriteArraySet, JobStateReasons
Declaration of Set Interface :
public interface Set<E>
extends Collection<E>
Set extends collection and specifies the behavior of a collection that does not contain duplicate elements. Therefore, the add() method returns false if we try to add any duplicate element to set.
This interface is a member of the Java Collections Framework.
Method Summary Of Set :
Modifier and Method Name
|
Description
|
boolean add(E e)
|
Appends the specified element to the end of this list (optional
operation).
|
boolean addAll(Collection<? extends E> c)
|
Adds all of the elements in the specified collection to this set if
they're not already present (optional operation).
|
void clear()
|
Removes all of the elements from this list (optional operation).
|
boolean contains(Object o)
|
Returns true if this list contains the specified element.
|
boolean containsAll(Collection<?> c)
|
Returns true if this list contains all of the elements of the
specified collection.
|
boolean equals(Object o)
|
Compares the specified object with this list for equality.
|
int hashCode()
|
Returns the hash code value for this list.
|
boolean isEmpty()
|
Returns true if this list contains no elements.
|
Iterator<E> iterator()
|
Returns an iterator over the elements in this list in proper
sequence.
|
boolean remove(Object o)
|
Removes the first occurrence of the specified element from this list,
if it is present (optional operation).
|
boolean removeAll(Collection<?> c)
|
Removes from this list all of its elements that are contained in the
specified collection (optional operation).
|
boolean retainAll(Collection<?> c)
|
Retains only the elements in this list that are contained in the
specified collection (optional operation).
|
int size()
|
Returns the number of elements in this list.
|
default Spliterator<E> spliterator()
|
Creates a Spliterator over the elements in this list.
|
Object[] toArray()
|
Returns an array containing all of the elements in this list in
proper sequence (from first to last element).
|
<T> T[] toArray(T[]
a)
|
Returns an array containing all of the elements in this list in
proper sequence (from first to last element); the runtime type of the
returned array is that of the specified array.
|
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.
This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.


No comments:
Post a Comment