1. Delete the arraylist set Element
When deleting elements in the arraylist set, the clear, remove, rmoveat, and removerange methods are provided.
The clear method removes all elements.
Ref: int [] arr = new int [] {1, 2, 3, 4, 5, 6 };
Arraylist list = new arraylist (ARR );
List. Clear ();
2. Remove Method
This method is used to remove a specific object from the arraylistFirst match
Ref: int arr = new int [] {1, 2, 3, 4, 5, 6 };
Arraylist list = new arraylist (ARR );
List. Remove (3 );
3. removeat Method
Used to remove the elements of the specified index in the arraylist.
Ref:
Int arr = new int [] {1, 2, 3, 4, 5, 6 };
Arraylist list = new arraylist (ARR );
List. removeat (3 );
4. removerange Method
This method is used to remove a certain range of elements from the arraylist.
Ref: int [] arr = new int [] {1, 2, 3, 4, 5, 6 };
Arraylist list = new arraylist (ARR );
List. removerange (3, 2 );
Search for arraylist set Elements
You can use the contain method, indexof method, and lastindexof method provided by the arraylist class.
1. contian Method
Used to determine whether an element is in the arraylist set.
2. indexof Method
Returns the index of the first matching item in the entire arraylist starting from scratch.
3. lastindexof Method
Returns the index of the last matching item in the entire arraylist starting from scratch.
Several arraylist operations