# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Methods | Inherited Methods

# ConcurrentHashMap.KeySetView

`public static class ConcurrentHashMap.KeySetView`
`extends Object` `implements Collection<K>, Serializable, Set<K>`

java.lang.Object
↳ | java.util.concurrent.ConcurrentHashMap.KeySetView<K, V>

A view of a ConcurrentHashMap as a `Set` of keys, in which additions may optionally be enabled by mapping to a common value. This class cannot be directly instantiated. See `keySet(V)`, `newKeySet()`, `newKeySet(int)`.

## Summary

### Public methods
`boolean` | `add(K e)` Adds the specified key to this set view by mapping the key to the default mapped value in the backing map, if defined.
`boolean` | `addAll(Collection<? extends K> c)` Adds all of the elements in the specified collection to this set, as if by calling `Set.add(E)` on each one.
`final void` | `clear()` Removes all of the elements from this view, by removing all the mappings from the map backing this view.
`boolean` | `contains(Object o)` Returns `true` if this collection contains the specified element.
`final boolean` | `containsAll(Collection<?> c)` Returns `true` if this collection contains all of the elements in the specified collection.
`boolean` | `equals(Object o)` Indicates whether some other object is "equal to" this one.
`void` | `forEach(Consumer<? super K> action)`
`ConcurrentHashMap<K, V>` | `getMap()` Returns the map backing this view.
`V` | `getMappedValue()` Returns the default mapped value for additions, or `null` if additions are not supported.
`int` | `hashCode()` Returns a hash code value for the object.
`final boolean` | `isEmpty()` Returns `true` if this collection contains no elements.
`Iterator<K>` | `iterator()` Returns an iterator over the elements in this collection.
`boolean` | `remove(Object o)` Removes the key from this map view, by removing the key (and its corresponding value) from the backing map.
`final boolean` | `removeAll(Collection<?> c)` Removes all of this collection's elements that are also contained in the specified collection (optional operation).
`final boolean` | `retainAll(Collection<?> c)` Retains only the elements in this collection that are contained in the specified collection (optional operation).
`final int` | `size()` Returns the number of elements in this collection.
`Spliterator<K>` | `spliterator()` Creates a `Spliterator` over the elements in this collection.
`final <T> T[]` | `toArray(T[] a)` Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
`final Object[]` | `toArray()` Returns an array containing all of the elements in this collection.
`final String` | `toString()` Returns a string representation of this collection.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `java.util.Collection`
`abstract boolean` | `add(K e)` Ensures that this collection contains the specified element (optional operation).
`abstract boolean` | `addAll(Collection<? extends E> c)` Adds all of the elements in the specified collection to this collection (optional operation).
`abstract void` | `clear()` Removes all of the elements from this collection (optional operation).
`abstract boolean` | `contains(Object o)` Returns `true` if this collection contains the specified element.
`abstract boolean` | `containsAll(Collection<?> c)` Returns `true` if this collection contains all of the elements in the specified collection.
`abstract boolean` | `equals(Object o)` Compares the specified object with this collection for equality.
`abstract int` | `hashCode()` Returns the hash code value for this collection.
`abstract boolean` | `isEmpty()` Returns `true` if this collection contains no elements.
`abstract Iterator<K>` | `iterator()` Returns an iterator over the elements in this collection.
`default Stream<K>` | `parallelStream()` Returns a possibly parallel `Stream` with this collection as its source.
`abstract boolean` | `remove(Object o)` Removes a single instance of the specified element from this collection, if it is present (optional operation).
`abstract boolean` | `removeAll(Collection<?> c)` Removes all of this collection's elements that are also contained in the specified collection (optional operation).
`default boolean` | `removeIf(Predicate<? super E> filter)` Removes all of the elements of this collection that satisfy the given predicate.
`abstract boolean` | `retainAll(Collection<?> c)` Retains only the elements in this collection that are contained in the specified collection (optional operation).
`abstract int` | `size()` Returns the number of elements in this collection.
`default Spliterator<K>` | `spliterator()` Creates a `Spliterator` over the elements in this collection.
`default Stream<K>` | `stream()` Returns a sequential `Stream` with this collection as its source.
`abstract <T> T[]` | `toArray(T[] a)` Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
`abstract Object[]` | `toArray()` Returns an array containing all of the elements in this collection.
From interface `java.util.Set`
`abstract boolean` | `add(K e)` Adds the specified element to this set if it is not already present (optional operation).
`abstract 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).
`abstract void` | `clear()` Removes all of the elements from this set (optional operation).
`abstract boolean` | `contains(Object o)` Returns `true` if this set contains the specified element.
`abstract boolean` | `containsAll(Collection<?> c)` Returns `true` if this set contains all of the elements of the specified collection.
`static <E> Set<K>` | `copyOf(Collection<? extends E> coll)` Returns an unmodifiable Set containing the elements of the given Collection.
`abstract boolean` | `equals(Object o)` Compares the specified object with this set for equality.
`abstract int` | `hashCode()` Returns the hash code value for this set.
`abstract boolean` | `isEmpty()` Returns `true` if this set contains no elements.
`abstract Iterator<K>` | `iterator()` Returns an iterator over the elements in this set.
`static <E> Set<K>` | `of(K e1, K e2, K e3)` Returns an immutable set containing three elements.
`static <E> Set<K>` | `of(K e1, K e2, K e3, K e4, K e5, K e6, K e7, K e8, K e9)` Returns an immutable set containing nine elements.
`static <E> Set<K>` | `of(K e1, K e2, K e3, K e4, K e5)` Returns an immutable set containing five elements.
`static <E> Set<K>` | `of(K e1, K e2, K e3, K e4, K e5, K e6)` Returns an immutable set containing six elements.
`static <E> Set<K>` | `of(K e1, K e2, K e3, K e4, K e5, K e6, K e7, K e8)` Returns an immutable set containing eight elements.
`static <E> Set<K>` | `of()` Returns an immutable set containing zero elements.
`static <E> Set<K>` | `of(K e1, K e2, K e3, K e4, K e5, K e6, K e7, K e8, K e9, K e10)` Returns an immutable set containing ten elements.
`static <E> Set<K>` | `of(K e1, K e2)` Returns an immutable set containing two elements.
`static <E> Set<K>` | `of(E... elements)` Returns an immutable set containing an arbitrary number of elements.
`static <E> Set<K>` | `of(K e1, K e2, K e3, K e4, K e5, K e6, K e7)` Returns an immutable set containing seven elements.
`static <E> Set<K>` | `of(K e1, K e2, K e3, K e4)` Returns an immutable set containing four elements.
`static <E> Set<K>` | `of(K e1)` Returns an immutable set containing one element.
`abstract boolean` | `remove(Object o)` Removes the specified element from this set if it is present (optional operation).
`abstract boolean` | `removeAll(Collection<?> c)` Removes from this set all of its elements that are contained in the specified collection (optional operation).
`abstract boolean` | `retainAll(Collection<?> c)` Retains only the elements in this set that are contained in the specified collection (optional operation).
`abstract int` | `size()` Returns the number of elements in this set (its cardinality).
`default Spliterator<K>` | `spliterator()` Creates a `Spliterator` over the elements in this set.
`abstract Object[]` | `toArray()` Returns an array containing all of the elements in this set.
`abstract <T> T[]` | `toArray(T[] a)` Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
From interface `java.lang.Iterable`
`default void` | `forEach(Consumer<? super T> action)` Performs the given action for each element of the `Iterable` until all elements have been processed or the action throws an exception.
`abstract Iterator<K>` | `iterator()` Returns an iterator over elements of type `T`.
`default Spliterator<K>` | `spliterator()` Creates a `Spliterator` over the elements described by this `Iterable`.
From interface `java.util.Collection`
`abstract boolean` | `add(K e)` Ensures that this collection contains the specified element (optional operation).
`abstract boolean` | `addAll(Collection<? extends E> c)` Adds all of the elements in the specified collection to this collection (optional operation).
`abstract void` | `clear()` Removes all of the elements from this collection (optional operation).
`abstract boolean` | `contains(Object o)` Returns `true` if this collection contains the specified element.
`abstract boolean` | `containsAll(Collection<?> c)` Returns `true` if this collection contains all of the elements in the specified collection.
`abstract boolean` | `equals(Object o)` Compares the specified object with this collection for equality.
`abstract int` | `hashCode()` Returns the hash code value for this collection.
`abstract boolean` | `isEmpty()` Returns `true` if this collection contains no elements.
`abstract Iterator<K>` | `iterator()` Returns an iterator over the elements in this collection.
`default Stream<K>` | `parallelStream()` Returns a possibly parallel `Stream` with this collection as its source.
`abstract boolean` | `remove(Object o)` Removes a single instance of the specified element from this collection, if it is present (optional operation).
`abstract boolean` | `removeAll(Collection<?> c)` Removes all of this collection's elements that are also contained in the specified collection (optional operation).
`default boolean` | `removeIf(Predicate<? super E> filter)` Removes all of the elements of this collection that satisfy the given predicate.
`abstract boolean` | `retainAll(Collection<?> c)` Retains only the elements in this collection that are contained in the specified collection (optional operation).
`abstract int` | `size()` Returns the number of elements in this collection.
`default Spliterator<K>` | `spliterator()` Creates a `Spliterator` over the elements in this collection.
`default Stream<K>` | `stream()` Returns a sequential `Stream` with this collection as its source.
`abstract <T> T[]` | `toArray(T[] a)` Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
`abstract Object[]` | `toArray()` Returns an array containing all of the elements in this collection.

## Public methods

### add

    public boolean add (K e)

Adds the specified key to this set view by mapping the key to the default mapped value in the backing map, if defined.

Parameters
`e` | `K`: key to be added

Returns
`boolean` | `true` if this set changed as a result of the call

Throws
`NullPointerException` | if the specified key is null
`UnsupportedOperationException` | if no default mapped value for additions was provided

### addAll

    public boolean addAll (Collection<? extends K> c)

Adds all of the elements in the specified collection to this set, as if by calling `Set.add(E)` on each one.

Parameters
`c` | `Collection`: the elements to be inserted into this set

Returns
`boolean` | `true` if this set changed as a result of the call

Throws
`NullPointerException` | if the collection or any of its elements are `null`
`UnsupportedOperationException` | if no default mapped value for additions was provided

### clear

    public final void clear ()

Removes all of the elements from this view, by removing all the mappings from the map backing this view.

### contains

    public boolean contains (Object o)

Returns `true` if this collection contains the specified element. More formally, returns `true` if and only if this collection contains at least one element `e` such that `(o==null ? e==null : o.equals(e))`.

Parameters
`o` | `Object`: element whose presence in this collection is to be tested

Returns
`boolean` | `true` if this collection contains the specified element

Throws
`NullPointerException` | if the specified key is null

### containsAll

    public final boolean containsAll (Collection<?> c)

Returns `true` if this collection contains all of the elements in the specified collection.

Parameters
`c` | `Collection`: collection to be checked for containment in this collection

Returns
`boolean` | `true` if this collection contains all of the elements in the specified collection

### equals

    public boolean equals (Object o)

Indicates whether some other object is "equal to" this one.

The `equals` method implements an equivalence relation on non-null object references:

- It is reflexive: for any non-null reference value `x`, `x.equals(x)` should return `true`.
- It is symmetric: for any non-null reference values `x` and `y`, `x.equals(y)` should return `true` if and only if `y.equals(x)` returns `true`.
- It is transitive: for any non-null reference values `x`, `y`, and `z`, if `x.equals(y)` returns `true` and `y.equals(z)` returns `true`, then `x.equals(z)` should return `true`.
- It is consistent: for any non-null reference values `x` and `y`, multiple invocations of `x.equals(y)` consistently return `true` or consistently return `false`, provided no information used in `equals` comparisons on the objects is modified.
- For any non-null reference value `x`, `x.equals(null)` should return `false`.

The `equals` method for class `Object` implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values `x` and `y`, this method returns `true` if and only if `x` and `y` refer to the same object (`x == y` has the value `true`).

Note that it is generally necessary to override the `hashCode` method whenever this method is overridden, so as to maintain the general contract for the `hashCode` method, which states that equal objects must have equal hash codes.

Parameters
`o` | `Object`: the reference object with which to compare.

Returns
`boolean` | `true` if this object is the same as the obj argument; `false` otherwise.

### forEach

    public void forEach (Consumer<? super K> action)

Parameters
`action` | `Consumer`

### getMap

    public ConcurrentHashMap<K, V> getMap ()

Returns the map backing this view.

Returns
`ConcurrentHashMap<K, V>` | the map backing this view

### getMappedValue

    public V getMappedValue ()

Returns the default mapped value for additions, or `null` if additions are not supported.

Returns
`V` | the default mapped value for additions, or `null` if not supported

### hashCode

    public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by `HashMap`.

The general contract of `hashCode` is:

- Whenever it is invoked on the same object more than once during an execution of a Java application, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the `equals(Object)` method, then calling the `hashCode` method on each of the two objects must produce the same integer result.
- It is not required that if two objects are unequal according to the `equals(java.lang.Object)` method, then calling the `hashCode` method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class `Object` does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

Returns
`int` | a hash code value for this object.

### isEmpty

    public final boolean isEmpty ()

Returns `true` if this collection contains no elements.

Returns
`boolean` | `true` if this collection contains no elements

### iterator

    public Iterator<K> iterator ()

Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).

Returns
`Iterator<K>` | an iterator over the keys of the backing map

### remove

    public boolean remove (Object o)

Removes the key from this map view, by removing the key (and its corresponding value) from the backing map. This method does nothing if the key is not in the map.

Parameters
`o` | `Object`: the key to be removed from the backing map

Returns
`boolean` | `true` if the backing map contained the specified key

Throws
`NullPointerException` | if the specified key is null

### removeAll

    public final boolean removeAll (Collection<?> c)

Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.

Parameters
`c` | `Collection`: collection containing elements to be removed from this collection

Returns
`boolean` | `true` if this collection changed as a result of the call

### retainAll

    public final boolean retainAll (Collection<?> c)

Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

Parameters
`c` | `Collection`: collection containing elements to be retained in this collection

Returns
`boolean` | `true` if this collection changed as a result of the call

### size

    public final int size ()

Returns the number of elements in this collection. If this collection contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.

Returns
`int` | the number of elements in this collection

### spliterator

    public Spliterator<K> spliterator ()

Creates a `Spliterator` over the elements in this collection. Implementations should document characteristic values reported by the spliterator. Such characteristic values are not required to be reported if the spliterator reports `Spliterator#SIZED` and this collection contains no elements.

The default implementation should be overridden by subclasses that can return a more efficient spliterator. In order to preserve expected laziness behavior for the `stream()` and `parallelStream()`} methods, spliterators should either have the characteristic of `IMMUTABLE` or `CONCURRENT`, or be late-binding. If none of these is practical, the overriding class should describe the spliterator's documented policy of binding and structural interference, and should override the `stream()` and `parallelStream()` methods to create streams using a `Supplier` of the spliterator, as in:

    Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)

These requirements ensure that streams produced by the `stream()` and `parallelStream()` methods will reflect the contents of the collection as of initiation of the terminal stream operation.

Returns
`Spliterator<K>` | a `Spliterator` over the elements in this collection

### toArray

    public final T[] toArray (T[] a)

Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.

If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to `null`. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any `null` elements.)

If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Like the `toArray()` method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose `x` is a collection known to contain only strings. The following code can be used to dump the collection into a newly allocated array of `String`:

         String[] y = x.toArray(new String[0]);

Note that `toArray(new Object[0])` is identical in function to `toArray()`.

Parameters
`a` | `T`: the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.

Returns
`T[]` | an array containing all of the elements in this collection

### toArray

    public final Object[] toArray ()

Returns an array containing all of the elements in this collection. If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Returns
`Object[]` | an array containing all of the elements in this collection

### toString

    public final String toString ()

Returns a string representation of this collection. The string representation consists of the string representations of the collection's elements in the order they are returned by its iterator, enclosed in square brackets (`"[]"`). Adjacent elements are separated by the characters `", "` (comma and space). Elements are converted to strings as by `String#valueOf(Object)`.

Returns
`String` | a string representation of this collection

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*