![]() ![]() Boolean addAll(Collection c): This takes a list as an argument and adds all the elements to the end of the current list. ![]() Void add(int index, E element): It takes two-parameter and adds elements t the specific index we mentioned.Add (E e): This method s used to add elements to the list.Boolean removeIf(Predicate filter): This method is used to remove the predicate passed.boolean removeAll(Collection c): This method is used to remove all the elements of the list.boolean remove(Object o): This method is used to remove the object, but it will remove the first occurrence as the list contain duplicate.Object toArray(): Return the array of object.void trimToSize(): This method will trim the list to the current list size.ArrayList(Collection c): List of a collection.įollowing are the methods of the java ArrayList class:.ArrayList(): By this, we can create an empty list without initial capacity, so in this case, the default initialCapacity would be 10.But ArrayList class takes care of it if the size exceeds the initialCapacity mentioned. ArrayList(int initialCapacity): In this, we can specify the initial length of the array list.In the array list, we have three constructors available, which are as follows: We can directly use an instance of ArrayList or assign it to a List reference. Web development, programming languages, Software testing & others Start Your Free Software Development Course
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |