Update some more features of ArrayList (#19874)

This commit is contained in:
Smruti Ranjan Rana
2018-10-26 08:35:53 +05:30
committed by Kristofer Koishigawa
parent 997cccd534
commit 03c2ca04f2

View File

@ -28,6 +28,12 @@ Since ArrayList implements *List*, an ArrayList can be created using the followi
An ArrayList is dynamic, meaning it will grow in size if required and similarly shrink in size if elements are deleted from it. This is what makes it better to use than normal arrays.
**Add elements to the list**
```java
variable.add(String e);
variable.add(int index, String element);
```
**Clear/Delete all elements from the list**
```java
variable.clear();
@ -48,6 +54,16 @@ Since ArrayList implements *List*, an ArrayList can be created using the followi
variable_name.set(index_number, element);
```
**Get the size of the list**
```java
variable_name.size();
```
**Get a sublist of the list**
```java
variable_name.subList(int fromIndex, int toIndex);
```
**Reverse elements in list**
import java.util.Collections // package
```java