The list inherits from the collection interface, and list is one of the collections. List is an ordered queue, none of the elements in the list will have an index, the first element index is 0, and the index value of the subsequent element allows duplicate elements in sequence +1,list. List Interface Source code:
Public Interfacelist<E>extendscollection<E> {intsize();//Size BooleanIsEmpty();//Determine if it is empty Booleancontains(Object o);//Determine if an object is included iterator<E>iterator();//Return Iteration Object Object[]ToArray(); //Returns an array of objects <T>T[]ToArray(T[] a);//Object array BooleanAdd(EE;//Add an object BooleanRemove(Object o);//Delete an object BooleanContainsall(collection<?> c); //Whether to include all objects of a collection BooleanAddAll(COLLECTION<?extendsE> C);//Append the collection object to the list BooleanAddAll(intIndex, collection<?extendsE> C);//Append Collection object to list in a certain location BooleanRemoveAll(collection<?> c);//Remove the objects contained in the collection BooleanRetainall(collection<?> c);//Remove objects that are not included in the collection default voidReplaceAll(unaryoperator<E> operator) {objects.requirenonnull (operator);Finallistiterator<E> li = This. Listiterator (); while(Li.hasnext ()) {Li.set (Operator.apply (Li.next ())); } }@SuppressWarnings({"Unchecked", "Rawtypes"})default voidSort(COMPARATOR<?SuperE> C) {object[] a = This. ToArray (); Arrays.sort (A, (Comparator) c); listiterator<E> i = This. Listiterator (); for(Object e:a) {i.next (); I.set ((EE; } }voidClear();//Delete all objects Booleanequals(Object o);//Determine if two lists are the same inthashcode();//Return to List of Hashcode EGet(intIndex;//Returns an object at a location ESet(intIndex, EElement;//Replace an object at a location voidAdd(intIndex, EElement;//Add an object in a location ERemove(intIndex;//Delete an object at a location intindexOf(Object o);//Returns the position of an object in the list intlastIndexOf(Object o);coordinates of the last object in the//list listiterator<E>Listiterator();//Returns an iteration of the entire list listiterator<E>Listiterator(intIndex; //Returns an iteration of the list starting from a location list<E>sublist(intFromIndex, intToindex);//Intercept part list @Override defaultspliterator<E>Spliterator() {returnSpliterators.spliterator (This ,spliterator.ordered); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java-list Source Code Analysis