You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: JavaArrayList/Readme.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,40 @@ import java.util.ArrayList; // import the ArrayList class
31
31
ArrayList<Boolean> list3 = new ArrayList<Boolean>();
32
32
```
33
33
34
+
| Methods | Description|
35
+
| :---------| :----------|
36
+
|`add(int index, Object element)`| This method is used to insert a specific element at a specific position index in a list. |
37
+
|`add(Object o)`| This method is used to append a specific element to the end of a list. |
38
+
|`addAll(Collection C)`| This method is used to append all the elements from a specific collection to the end of the mentioned list, in such an order that the values are returned by the specified collection’s iterator. |
39
+
|`addAll(int index, Collection C)`| Used to insert all of the elements starting at the specified position from a specific collection into the mentioned list. |
40
+
|`clear()`| This method is used to remove all the elements from any list. |
41
+
|`clone()`| This method is used to return a shallow copy of an ArrayList. |
42
+
|`contains?(Object o)`| Returns true if this list contains the specified element. |
43
+
|`ensureCapacity?(int minCapacity)`| Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
44
+
|`forEach?(Consumer<? super E> action)`| Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. |
45
+
|`get?(int index)`| Returns the element at the specified position in this list. |
46
+
|`indexOf(Object O)`| The index the first occurrence of a specific element is either returned, or -1 in case the element is not in the list. |
47
+
|`isEmpty?()`| Returns true if this list contains no elements. |
48
+
|`lastIndexOf(Object O)`| The index of the last occurrence of a specific element is either returned or -1 in case the element is not in the list. |
49
+
|`listIterator?()`| Returns a list iterator over the elements in this list (in proper sequence). |
50
+
|`listIterator?(int index)`| Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. |
51
+
|`remove?(int index)`| Removes the element at the specified position in this list. |
52
+
|`remove?(Object o)`| Removes the first occurrence of the specified element from this list, if it is present. |
53
+
|`removeAll?(Collection c)`| Removes from this list all of its elements that are contained in the specified collection. |
54
+
|`removeIf?(Predicate filter)`| Removes all of the elements of this collection that satisfy the given predicate. |
55
+
|`removeRange?(int fromIndex, int toIndex)`| Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive. |
56
+
|`retainAll?(Collection<?> c)`| Retains only the elements in this list that are contained in the specified collection. |
57
+
|`set?(int index, E element)`| Replaces the element at the specified position in this list with the specified element. |
58
+
|`size?()`| Returns the number of elements in this list. |
59
+
|`spliterator?()`| Creates a late-binding and fail-fast Spliterator over the elements in this list. |
60
+
|`subList?(int fromIndex, int toIndex)`| Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. |
61
+
|`toArray()`| This method is used to return an array containing all of the elements in the list in the correct order. |
62
+
|`toArray(Object[] O)`| It is also used to return an array containing all of the elements in this list in the correct order same as the previous method. |
63
+
|`trimToSize()`| This method is used to trim the capacity of the instance of the ArrayList to the list’s current size. |
64
+
65
+
66
+
67
+
34
68
### `add()`
35
69
It is used to append the specified element at the end of a list.
0 commit comments