【remove】 This method is used to delete the elements of ArrayList. Specify the index of the element you want to delete and use it as shown below. Variable name.remove (index)
In the ArrayList "array" used in Java (add) times Remove the element at the location specified by the remove method.
ArrayList<String> array = new ArrayList<String>();
array.add ("Japanese"); array.add ("English"); array.add ("French"); array.add ("Chinese"); array.add ("German");
System.out.println(array);
[Japanese, English, French, Chinese, German]
Delete "French" in index 2.
array.remove(2);
System.out.println(array);
The output in the list is as follows.
[Japanese, English, Chinese, German]
The value of the specified element is deleted.
Recommended Posts