EnumSet class Methods in Java Part-II

java.util.EnumSet<K>

A specialized Set implementation for use with enum types. All of the elements in an enum set must come from a single enum type that is specified, explicitly or implicitly, when the set is created.


Some Methods of EnumSet.


EnumSet.of(K, K...): This method creates an enum set initially containing the specified elements.


EnumSet.of(K, K, K):


EnumSet.of(K, K, K, K):


EnumSet.of(K, K, K, K, K): 


parallelStream(): This method returns a possibly parallel Stream with this collection as its source.


EnumSet.range(K, K): This method creates an enum set initially containing all of the elements in the range defined by the two specified endpoints.


remove(Object): This method removes a single instance of the specified element from this collection if it is present.


removeAll(Collection): This method removes from this set all of its elements that are contained in the specified collection.


retainAll(Collection): This method retains only the elements in this collection that are contained in the specified collection.


size(): This method returns the number of elements in this collection.


spliterator(): This method creates a Spliterator over the elements in this set.


stream(): This method returns a sequential Stream with this collection as its source.


toArray(): This method returns an array containing all of the elements in this collection.


toArray(IntFunction): This method returns an array containing all of the elements in this collection, using the provided generator function to allocate the returned array.


toString(): This method returns a string representation of this collection.


Some more Methods of EnumSet class


No comments:

Post a Comment