Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/icu/text/ListFormatter#nestedclasses) \| [Methods](https://developer.android.com/reference/android/icu/text/ListFormatter#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/icu/text/ListFormatter#inhmethods)

# ListFormatter

*** ** * ** ***

` public final class ListFormatter `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.icu.text.ListFormatter |

<br />

*** ** * ** ***

Immutable class for formatting a list, using data from CLDR (or supplied separately). The class is not subclassable.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/icu/text/ListFormatter.FormattedList` An immutable class containing the result of a list formatting operation. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#format(java.util.Collection<?>)(https://developer.android.com/reference/java/util/Collection<?> items) ` Format a collection of objects. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#format(java.lang.Object[])(https://developer.android.com/reference/java/lang/Object items) ` Format a list of objects. |
| ` https://developer.android.com/reference/android/icu/text/ListFormatter.FormattedList` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#formatToValue(java.lang.Object[])(https://developer.android.com/reference/java/lang/Object items) ` Format a list of objects to a FormattedList. |
| ` https://developer.android.com/reference/android/icu/text/ListFormatter.FormattedList` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#formatToValue(java.util.Collection<?>)(https://developer.android.com/reference/java/util/Collection<?> items) ` Format a collection of objects to a FormattedList. |
| ` static https://developer.android.com/reference/android/icu/text/ListFormatter` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#getInstance(java.util.Locale,%20android.icu.text.ListFormatter.Type,%20android.icu.text.ListFormatter.Width)(https://developer.android.com/reference/java/util/Locale locale, https://developer.android.com/reference/android/icu/text/ListFormatter.Type type, https://developer.android.com/reference/android/icu/text/ListFormatter.Width width) ` Create a list formatter that is appropriate for a locale. |
| ` static https://developer.android.com/reference/android/icu/text/ListFormatter` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#getInstance(android.icu.util.ULocale)(https://developer.android.com/reference/android/icu/util/ULocale locale) ` Create a list formatter that is appropriate for a locale. |
| ` static https://developer.android.com/reference/android/icu/text/ListFormatter` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#getInstance()() ` Create a list formatter that is appropriate for the default FORMAT locale. |
| ` static https://developer.android.com/reference/android/icu/text/ListFormatter` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#getInstance(java.util.Locale)(https://developer.android.com/reference/java/util/Locale locale) ` Create a list formatter that is appropriate for a locale. |
| ` static https://developer.android.com/reference/android/icu/text/ListFormatter` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#getInstance(android.icu.util.ULocale,%20android.icu.text.ListFormatter.Type,%20android.icu.text.ListFormatter.Width)(https://developer.android.com/reference/android/icu/util/ULocale locale, https://developer.android.com/reference/android/icu/text/ListFormatter.Type type, https://developer.android.com/reference/android/icu/text/ListFormatter.Width width) ` Create a list formatter that is appropriate for a locale. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/icu/text/ListFormatter#getPatternForNumItems(int)(int count) ` Returns the pattern to use for a particular item count. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public methods

### format

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

```
public String format (Collection<?> items)
```

Format a collection of objects. The toString() method is called on each.

<br />

| Parameters ||
|---|---|
| `items` | `Collection`: items to format. The toString() method is called on each. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | items formatted into a string <br /> |

### format

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

```
public String format (Object... items)
```

Format a list of objects.

<br />

| Parameters ||
|---|---|
| `items` | `Object`: items to format. The toString() method is called on each. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | items formatted into a string <br /> |

### formatToValue

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

```
public ListFormatter.FormattedList formatToValue (Object... items)
```

Format a list of objects to a FormattedList. You can access the offsets of each element from the FormattedList.

<br />

| Parameters ||
|---|---|
| `items` | `Object`: items to format. The toString() method is called on each. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/ListFormatter.FormattedList` | items formatted into a FormattedList <br /> |

### formatToValue

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

```
public ListFormatter.FormattedList formatToValue (Collection<?> items)
```

Format a collection of objects to a FormattedList. You can access the offsets of each element from the FormattedList.

<br />

| Parameters ||
|---|---|
| `items` | `Collection`: items to format. The toString() method is called on each. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/ListFormatter.FormattedList` | items formatted into a FormattedList <br /> |

### getInstance

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

```
public static ListFormatter getInstance (Locale locale, 
                ListFormatter.Type type, 
                ListFormatter.Width width)
```

Create a list formatter that is appropriate for a locale.

<br />

| Parameters ||
|---|---|
| `locale` | `Locale`: the locale in question. <br /> |
| `type` | `ListFormatter.Type` <br /> |
| `width` | `ListFormatter.Width` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/ListFormatter` | ListFormatter <br /> |

### getInstance

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

```
public static ListFormatter getInstance (ULocale locale)
```

Create a list formatter that is appropriate for a locale.

<br />

| Parameters ||
|---|---|
| `locale` | `ULocale`: the locale in question. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/ListFormatter` | ListFormatter <br /> |

### getInstance

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

```
public static ListFormatter getInstance ()
```

Create a list formatter that is appropriate for the default FORMAT locale.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/ListFormatter` | ListFormatter <br /> |

### getInstance

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

```
public static ListFormatter getInstance (Locale locale)
```

Create a list formatter that is appropriate for a locale.

<br />

| Parameters ||
|---|---|
| `locale` | `Locale`: the locale in question. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/ListFormatter` | ListFormatter <br /> |

### getInstance

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

```
public static ListFormatter getInstance (ULocale locale, 
                ListFormatter.Type type, 
                ListFormatter.Width width)
```

Create a list formatter that is appropriate for a locale.

<br />

| Parameters ||
|---|---|
| `locale` | `ULocale`: the locale in question. <br /> |
| `type` | `ListFormatter.Type` <br /> |
| `width` | `ListFormatter.Width` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/icu/text/ListFormatter` | ListFormatter <br /> |

### getPatternForNumItems

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

```
public String getPatternForNumItems (int count)
```

Returns the pattern to use for a particular item count.

<br />

| Parameters ||
|---|---|
| `count` | `int`: the item count. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the pattern with {0}, {1}, {2}, etc. For English, getPatternForNumItems(3) == "{0}, {1}, and {2}" <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | when count is 0 or negative. |