# ConcurrentHashMap.KeySetView

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# KeySetView

```
class KeySetView<K : Any!, V : Any!> : MutableCollection<K>, Serializable, MutableSet<K>
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                         ||
| ↳ | [java.util.concurrent.ConcurrentHashMap.KeySetView](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#) |

A view of a ConcurrentHashMap as a[Set](https://developer.android.com/reference/kotlin/java/util/Set.html#)of keys, in which additions may optionally be enabled by mapping to a common value. This class cannot be directly instantiated. See[keySet(V)](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap#keySet(java.util.concurrent.ConcurrentHashMap.V)),[newKeySet()](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap#newKeySet()),[newKeySet(int)](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap#newKeySet(kotlin.Int)).

## Summary

|                                                                                                                                                                                                                                                                                                                                             Public methods                                                                                                                                                                                                                                                                                                                                              ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [add](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#add(java.util.concurrent.ConcurrentHashMap.KeySetView.K))`(`element:` `K`)` Adds the specified key to this set view by mapping the key to the default mapped value in the backing map, if defined.                                                                                                                                                                                                                                |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [addAll](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#addAll(kotlin.collections.Collection))`(`elements:` `[Collection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)<K>`)` Adds all of the elements in the specified collection to this set, as if by calling[add](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#add(java.util.concurrent.ConcurrentHashMap.KeySetView.K))on each one. |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                  | [clear](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#clear())`()` Removes all of the elements from this view, by removing all the mappings from the map backing this view.                                                                                                                                                                                                                                                                                                           |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [contains](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#contains(java.util.concurrent.ConcurrentHashMap.KeySetView.K))`(`element:` `K`)` Returns`true`if this collection contains the specified element.                                                                                                                                                                                                                                                                             |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [containsAll](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#containsAll(kotlin.collections.Collection))`(`elements:` `[Collection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)<K>`)` <br />                                                                                                                                                                                                                                               |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [equals](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` <br />                                                                                                                                                                                                                                                                                                           |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                                                                                  | [forEach](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#forEach(java.util.function.Consumer))`(`action:` `[Consumer](https://developer.android.com/reference/kotlin/java/util/function/Consumer.html#)<in` `K>`)` <br />                                                                                                                                                                                                                                                              |
| [ConcurrentHashMap](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap)\<K,V\>                                             | [getMap](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#getMap())`()` Returns the map backing this view.                                                                                                                                                                                                                                                                                                                                                                               |
| V?                                                                                                                                                            | [getMappedValue](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#getMappedValue())`()` Returns the default mapped value for additions, or`null`if additions are not supported.                                                                                                                                                                                                                                                                                                          |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                                                                                    | [hashCode](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#hashCode())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [isEmpty](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#isEmpty())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                         |
| [MutableIterator](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-iterator/index.html)\<K\>                                          | [iterator](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#iterator())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [remove](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#remove(java.util.concurrent.ConcurrentHashMap.KeySetView.K))`(`element:` `K`)` Removes the key from this map view, by removing the key (and its corresponding value) from the backing map.                                                                                                                                                                                                                                     |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [removeAll](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#removeAll(kotlin.collections.Collection))`(`elements:` `[Collection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)<K>`)` <br />                                                                                                                                                                                                                                                   |
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                            | [retainAll](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#retainAll(kotlin.collections.Collection))`(`elements:` `[Collection](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html)<K>`)` <br />                                                                                                                                                                                                                                                   |
| [Spliterator](https://developer.android.com/reference/kotlin/java/util/Spliterator.html#)\<K\>                                                                | [spliterator](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#spliterator())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                 |
| [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!\> | [toArray](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#toArray())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                         |
| [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<T\>                                                                           | [toArray](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#toArray(kotlin.Array))`(`a:` `[Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<T>`)` <br />                                                                                                                                                                                                                                                                                                     |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                                                                              | [toString](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#toString())`()` Returns a string representation of this collection.                                                                                                                                                                                                                                                                                                                                                          |

|                                                                                                 Properties                                                                                                  ||
|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [size](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#size:kotlin.Int) <br /> |

## Public methods

### add

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun add(element: K): Boolean
```

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` | key to be added |

|                                                                Return                                                                 ||
|------------------------------------------------------------------------------------|---------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this set changed as a result of the call |

|                                                          Exceptions                                                           ||
|-------------------------------------------|------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException` | if no default mapped value for additions was provided                              |
| `java.lang.ClassCastException`            | if the class of the specified element prevents it from being added to this set     |
| `java.lang.NullPointerException`          | if the specified key is null                                                       |
| `java.lang.IllegalArgumentException`      | if some property of the specified element prevents it from being added to this set |
| `java.lang.IllegalStateException`         | if the element cannot be added at this time due to insertion restrictions          |

### addAll

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun addAll(elements: Collection<K>): Boolean
```

Adds all of the elements in the specified collection to this set, as if by calling[add](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap.KeySetView#add(java.util.concurrent.ConcurrentHashMap.KeySetView.K))on each one.

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

|                                                                Return                                                                 ||
|------------------------------------------------------------------------------------|---------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this set changed as a result of the call |

|                                                                   Exceptions                                                                   ||
|-------------------------------------------|-----------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException` | if no default mapped value for additions was provided                                               |
| `java.lang.ClassCastException`            | if the class of an element of the specified collection prevents it from being added to this set     |
| `java.lang.NullPointerException`          | if the collection or any of its elements are`null`                                                  |
| `java.lang.IllegalArgumentException`      | if some property of an element of the specified collection prevents it from being added to this set |
| `java.lang.IllegalStateException`         | if not all the elements can be added at this time due to insertion restrictions                     |

### clear

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun clear(): Unit
```

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

|                                         Exceptions                                          ||
|-------------------------------------------|--------------------------------------------------|
| `java.lang.UnsupportedOperationException` | if the`clear`method is not supported by this set |

### contains

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun contains(element: K): Boolean
```

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`Objects.equals(o, e)`.

|                       Parameters                        ||
|-----|----------------------------------------------------|
| `o` | element whose presence in this set is to be tested |

|                                                                Return                                                                ||
|------------------------------------------------------------------------------------|--------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this set contains the specified element |

|                                                                                                       Exceptions                                                                                                        ||
|----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.ClassCastException`   | if the type of the specified element is incompatible with this set ([optional](https://developer.android.com/reference/kotlin/java/util/concurrent/Collection#optional-restrictions)) |
| `java.lang.NullPointerException` | if the specified key is null                                                                                                                                                          |

### containsAll

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun containsAll(elements: Collection<K>): Boolean
```

|                        Parameters                         ||
|-----|------------------------------------------------------|
| `c` | collection to be checked for containment in this set |

|                                                                             Return                                                                             ||
|------------------------------------------------------------------------------------|----------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this set contains all of the elements of the specified collection |

|                                                                                                                                               Exceptions                                                                                                                                               ||
|----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.ClassCastException`   | if the types of one or more elements in the specified collection are incompatible with this set ([optional](https://developer.android.com/reference/kotlin/java/util/concurrent/Collection#optional-restrictions))                                                   |
| `java.lang.NullPointerException` | if the specified collection contains one or more null elements and this set does not permit null elements ([optional](https://developer.android.com/reference/kotlin/java/util/concurrent/Collection#optional-restrictions)), or if the specified collection is null |

### equals

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun equals(other: Any?): Boolean
```

|                       Parameters                        ||
|-------|--------------------------------------------------|
| `obj` | the reference object with which to compare.      |
| `o`   | object to be compared for equality with this set |

|                                                                 Return                                                                 ||
|------------------------------------------------------------------------------------|----------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the specified object is equal to this set |

### forEach

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun forEach(action: Consumer<in K>): Unit
```

|                                                                        Parameters                                                                         ||
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `action` | [Consumer](https://developer.android.com/reference/kotlin/java/util/function/Consumer.html#)\<inK\>:The action to be performed for each element |

|                            Exceptions                             ||
|----------------------------------|---------------------------------|
| `java.lang.NullPointerException` | if the specified action is null |

### getMap

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getMap(): ConcurrentHashMap<K, V>
```

Returns the map backing this view.

|                                                                    Return                                                                     ||
|--------------------------------------------------------------------------------------------------------------------|---------------------------|
| [ConcurrentHashMap](https://developer.android.com/reference/kotlin/java/util/concurrent/ConcurrentHashMap)<K,` `V> | the map backing this view |

### getMappedValue

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getMappedValue(): V?
```

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

|                                Return                                ||
|----|------------------------------------------------------------------|
| V? | the default mapped value for additions, or`null`if not supported |

### hashCode

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun hashCode(): Int
```

|                                                    Return                                                    ||
|----------------------------------------------------------------------------|----------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the hash code value for this set |

### isEmpty

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun isEmpty(): Boolean
```

|                                                           Return                                                           ||
|------------------------------------------------------------------------------------|----------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this set contains no elements |

### iterator

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun iterator(): MutableIterator<K>
```

|                                                                              Return                                                                              ||
|--------------------------------------------------------------------------------------------------------------------|----------------------------------------------|
| [MutableIterator](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-iterator/index.html)<K> | an iterator over the keys of the backing map |

### remove

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun remove(element: K): Boolean
```

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` | the key to be removed from the backing map |

|                                                                  Return                                                                  ||
|------------------------------------------------------------------------------------|------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if the backing map contained the specified key |

|                                                                                                            Exceptions                                                                                                            ||
|-------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.ClassCastException`            | if the type of the specified element is incompatible with this set ([optional](https://developer.android.com/reference/kotlin/java/util/concurrent/Collection#optional-restrictions)) |
| `java.lang.NullPointerException`          | if the specified key is null                                                                                                                                                          |
| `java.lang.UnsupportedOperationException` | if the`remove`operation is not supported by this set                                                                                                                                  |

### removeAll

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun removeAll(elements: Collection<K>): Boolean
```

|                           Parameters                            ||
|-----|------------------------------------------------------------|
| `c` | collection containing elements to be removed from this set |

|                                                                Return                                                                 ||
|------------------------------------------------------------------------------------|---------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this set changed as a result of the call |

|                                                                                                                                              Exceptions                                                                                                                                              ||
|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException` | if the`removeAll`operation is not supported by this set                                                                                                                                                                                                   |
| `java.lang.ClassCastException`            | if the class of an element of this set is incompatible with the specified collection ([optional](https://developer.android.com/reference/kotlin/java/util/concurrent/Collection#optional-restrictions))                                                   |
| `java.lang.NullPointerException`          | if this set contains a null element and the specified collection does not permit null elements ([optional](https://developer.android.com/reference/kotlin/java/util/concurrent/Collection#optional-restrictions)), or if the specified collection is null |

### retainAll

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun retainAll(elements: Collection<K>): Boolean
```

|                           Parameters                           ||
|-----|-----------------------------------------------------------|
| `c` | collection containing elements to be retained in this set |

|                                                                Return                                                                 ||
|------------------------------------------------------------------------------------|---------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true`if this set changed as a result of the call |

|                                                                                                                                              Exceptions                                                                                                                                              ||
|-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.UnsupportedOperationException` | if the`retainAll`operation is not supported by this set                                                                                                                                                                                                   |
| `java.lang.ClassCastException`            | if the class of an element of this set is incompatible with the specified collection ([optional](https://developer.android.com/reference/kotlin/java/util/concurrent/Collection#optional-restrictions))                                                   |
| `java.lang.NullPointerException`          | if this set contains a null element and the specified collection does not permit null elements ([optional](https://developer.android.com/reference/kotlin/java/util/concurrent/Collection#optional-restrictions)), or if the specified collection is null |

### spliterator

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun spliterator(): Spliterator<K>
```

|                                                                  Return                                                                   ||
|----------------------------------------------------------------------------------------------|---------------------------------------------|
| [Spliterator](https://developer.android.com/reference/kotlin/java/util/Spliterator.html#)<K> | a`Spliterator`over the elements in this set |

### toArray

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun toArray(): Array<Any!>
```

|                                                                                                    Return                                                                                                     ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)!> | an array containing all the elements in this set |

### toArray

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun <T : Any!> toArray(a: Array<T>): Array<T>
```

|                                                                                                                           Parameters                                                                                                                           ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `<T>` | the component type of the array to contain the collection                                                                                                                                                                                               |
| `a`   | [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)\<T\>:the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose. |

|                                                               Return                                                                ||
|-----------------------------------------------------------------------------------|--------------------------------------------------|
| [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)<T> | an array containing all the elements in this set |

|                                                                    Exceptions                                                                    ||
|----------------------------------|----------------------------------------------------------------------------------------------------------------|
| `java.lang.ArrayStoreException`  | if the runtime type of the specified array is not a supertype of the runtime type of every element in this set |
| `java.lang.NullPointerException` | if the specified array is null                                                                                 |

### toString

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun toString(): String
```

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)](https://developer.android.com/reference/kotlin/java/lang/String.html#valueOf(kotlin.Any)).

|                                                            Return                                                            ||
|----------------------------------------------------------------------------------|--------------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of this collection |

## Properties

### size

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
val size: Int
```

|                                                              Return                                                              ||
|----------------------------------------------------------------------------|------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the number of elements in this set (its cardinality) |