There is a remove method and a RemoveAll method in the ArrayList,
ArrayList not only inherits the Remove method in interface collection, but also expands the Remove method.
The interface declared in collection is public, Boolean remove (Object o)
public boolean RemoveAll (collection<?> c)
The method contained in ArrayList is public E remove (int index)
The remove interface may be called via a collection in the actual programming, in which case no error is made, but the program does nothing.
Import Java.util.arraylist;import Java.util.collection;import Java.util.list;public class ArrayList01 {public static void Main (string[] args) {//TODO auto-generated method stublist<string> alllist = null; collection<string> allcollection = null;alllist = new arraylist<string> (); allcollection = new ArrayList< String> (); Alllist.add ("Hello"); Alllist.add (0, "World"); System.out.println (alllist); Allcollection.add ("Yes") Allcollection.add ("good"); Alllist.addall (allcollection); Alllist.addall (0, allcollection); System.out.println (alllist); Alllist.remove (allcollection); Alllist.removeall (allcollection); System.out.println (alllist);}}
Actual programming can insert arbitrary objects, but if you want to remove an object by removing (object o), the object must be a system-defined object, and if not, you need to overwrite the Equals () and Hashcode () methods of the object class in the class.
ArrayList call the Remove method where you need to be aware