Deleting elements is as easy as adding them. The counterpart of append() is the pop() operation which removes the last element from the list.
We can store this popped element in a variable:
There are multiple ways to delete an element from an ArrayBuffer. Let’s look at the ones which are most commonly used.
For all the examples below, we will be working with newArrayBuff. Remember that our original ArrayBuffer contains the elements
[
6
,
15
,
78
,
4
,
32
,
11
]
[6,15,78,4,32,11]
.
-= Assignment Operator
The same way we add an element using +=, we can remove a specific element using -=.