Add is to store the incoming parameter as an item in the current list, even if you pass in a list and only add 1 elements to the current list.
AddAll is to pass in a list, adding all the elements of this list to the current list, that is, the number of elements that the current list adds to the size of the incoming list
That
AddAll (Collection C) Add (int index, ELELEMT e)-------------------------------------- AddAll (Collection c)
This method adds all the elements in the collection to the end of the list, in order of the elements returned by the iterator that specifies collection. If the specified collection is modified while this operation is in progress, the behavior of this operation is indeterminate (which means that if the specified collection is this list and the list is non-null, the behavior of the call is indeterminate).
C contains the collection of the elements to be added to this list
Return TRUE if this list has been changed due to a call
NullPointerException: If the specified collection is null
Throws
Eg:collection result = new ArrayList (); Collection list = new ArrayList (); Analysis: result.addall (list); Add each element in the list to result, result.size () = = List.size () result.add (list); Add list as an element to result, then Result.size () is 1
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The difference between the List's Add () and AddAll ()