> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **ArrayList** instance.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fromIndex | number | Yes| Index of the start position.|
| toIndex | number | Yes| Index of the end position.|
**Return value**
| Type| Description|
| -------- | -------- |
| ArrayList<T> | New **ArrayList** instance obtained.|
**Example**
```
let arrayList = new ArrayList();
arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result1 = arrayList.subArrayList(2, 4);
let result2 = arrayList.subArrayList(4, 3);
let result3 = arrayList.subArrayList(2, 6);
```
### clear
clear(): void
Clears this container and sets its length to **0**.
**Example**
```
let arrayList = new ArrayList();
arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.clear();
```
### clone
clone(): ArrayList<T>
Clones this container and returns a copy. The modification to the copy does not affect the original instance.
**Return value**
| Type| Description|
| -------- | -------- |
| ArrayList<T> | New **ArrayList** instance obtained.|
**Example**
```
let arrayList = new ArrayList();
arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.clone();
```
### getCapacity
getCapacity(): number
Obtains the capacity of this container.
**Return value**
| Type| Description|
| -------- | -------- |
| number | Capacity obtained.|
**Example**
```
let arrayList = new ArrayList();
arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.getCapacity();
```
### convertToArray
convertToArray(): Array<T>
Converts this container into an array.
**Return value**
| Type| Description|
| -------- | -------- |
| Array<T> | Array obtained.|
**Example**
```
let arrayList = new ArrayList();
arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.convertToArray();
```
### isEmpty
isEmpty(): boolean
Checks whether this container is empty (contains no entry).
**Return value**
| Type| Description|
| -------- | -------- |
| boolean | Returns **true** if the container is empty; returns **false** otherwise.|
**Example**
```
let arrayList = new ArrayList();
arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
let result = arrayList.isEmpty();
```
### increaseCapacityTo
increaseCapacityTo(newCapacity: number): void
Increases the capacity of this container.
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| newCapacity | number | Yes| New capacity.|
**Example**
```
let arrayList = new ArrayList();
arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.increaseCapacityTo(2);
arrayList.increaseCapacityTo(8);
```
### trimToCurrentLength
trimToCurrentLength(): void
Trims the capacity of this container to its current length.
**Example**
```
let arrayList = new ArrayList();
arrayList.add(2);
arrayList.add(4);
arrayList.add(5);
arrayList.add(4);
arrayList.trimToCurrentLength();
```
### [Symbol.iterator]
[Symbol.iterator]\(): IterableIterator<T>
Obtains an iterator, each item of which is a JavaScript object.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import LightWeightSet from '@ohos.util.LightWeightSet'
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Obtains entries within a range in this container, including the entry at the start position but not that at the end position, and returns these entries as a new **List** instance.
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| fromIndex | number | Yes| Index of the start position.|
| toIndex | number | Yes| Index of the end position.|
**Return value**
| Value Type | Description|
| -------- | -------- |
| List<T> | New **List** instance obtained.|
**Example**
```
let list = new List();
list.add(2);
list.add(4);
list.add(5);
list.add(4);
let result = list.subList(2, 4);
let result1 = list.subList(4, 3);
let result2 = list.subList(2, 6);
```
### clear
clear(): void
Clears this container and sets its length to **0**.
**Example**
```
let list = new List();
list.add(2);
list.add(4);
list.add(5);
list.add(4);
list.clear();
```
### set
set(index: number, element: T): T
Replaces an entry at the specified position in this container with a given entry.
**Parameters**
| Name| Value Type | Mandatory| Description|
| -------- | -------- | -------- | -------- |
| index | number | Yes| Position index of the entry to replace.|
| element | T | Yes| Entry to be used for replacement.|
**Return value**
| Value Type | Description|
| -------- | -------- |
| T | New entry.|
**Example**
```
let list = new List();
list.add(2);
list.add(4);
list.add(5);
list.add(4);
list.set(2, "b");
```
### convertToArray
convertToArray(): Array<T>
Converts this container into an array.
**Return value**
| Value Type | Description|
| -------- | -------- |
| Array<T> | Array obtained.|
**Example**
```
let list = new List();
list.add(2);
list.add(4);
list.add(5);
list.add(4);
let result = list.convertToArray();
```
### isEmpty
isEmpty(): boolean
Checks whether this container is empty (contains no entry).
**Return value**
| Value Type | Description|
| -------- | -------- |
| boolean | Returns **true** if the container is empty; returns **false** otherwise.|
**Example**
```
let list = new List();
list.add(2);
list.add(4);
list.add(5);
list.add(4);
let result = list.isEmpty();
```
### getFirst
getFirst(): T
Obtains the first entry in this container.
**Return value**
| Value Type | Description|
| -------- | -------- |
| T | The first entry obtained.|
**Example**
```
let list = new Vector();
list.add(2);
list.add(4);
list.add(5);
list.add(4);
let result = list.getFirst();
```
### getLast
getLast(): T
Obtains the last entry in this container.
**Return value**
| Value Type | Description|
| -------- | -------- |
| T | The last entry obtained.|
**Example**
```
let list = new Vector();
list.add(2);
list.add(4);
list.add(5);
list.add(4);
let result = list.getLast();
```
### [Symbol.iterator]
[Symbol.iterator]\(): IterableIterator<T>;
Obtains an iterator, each item of which is a JavaScript object.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.