ArrayList clone() method is used to create a shallow copy of the list. In the new list, only object references are copied. If we change the object state inside first arraylist, then changed object state will be reflected in cloned arraylist as well. 1. ArrayList clone() method clone() method create a new arraylist and then […]
ArrayList clear() method is used to removes all of the elements from the list. The list will be empty after this call returns.
ArrayList addAll() method is used to append all of the elements of argument collection to the list at the end. The order of appended elements is that they are returned by the argument collection’s Iterator.
ArrayList add() method is used to add an element in the list. We can add elements of any type in arraylist, but make program behave in more predicatable manner, we should add elements of one certain type only in any goven list instance. Use generics for compile time type safety while adding the element to […]
Java LinkedList vs ArrayList. Both are different in many aspects and we need to understand both to make a wise decision when to use which class.