How much data can be added in java.util.List in Java at the maximum Is there any default size an array list?
As much as your available memory will allow. There's no size limit except for the heap.
It would depend on the implementation, but the limit is not defined by the List interface.
The interface however defines the size() method, which returns an int.
Returns the number of elements in this list. If this list contains more than
Integer.MAX_VALUEelements, returnsInteger.MAX_VALUE.
So, no limit, but after you reach Integer.MAX_VALUE, the behaviour of the list changes a bit
ArrayList (which is tagged) is backed by an array, and is limited to the size of the array - i.e. Integer.MAX_VALUE
java.util.List is an interface. How much data a list can hold is dependant on the specific implementation of List you choose to use.
Generally, a List implementation can hold any number of items (If you use an indexed List, it may be limited to Integer.MAX_VALUE or Long.MAX_VALUE). As long as you don't run out of memory, the List doesn't become "full" or anything.
How much data can be added in java.util.List in Java at the maximum?
The interface java.util.List has no documented limit on the maximum number of elements of a class that implements this interface. However, I suspect that a class allowing for more than Integer.MAX_VALUE (231-1 = 2147483647) elements would have trouble implementing certain methods faithfully, such as List.toArray which according to documentation should...
Return an array containing all of the elements in this list in proper sequence (from first to last element);
... since the size of an array is limited by Integer.MAX_VALUE.
Is there any default size an array list?
If you're referring to ArrayList then I'd say that the default size is 0. The default capacity however (the number of elements you can insert, without forcing the list to reallocate memory) is 10. See the documentation of the default constructor.
The size limit of ArrayList is Integer.MAX_VALUE since it's backed by an ordinary array.
It depends on the List implementation. Since you index arrays with ints, an ArrayList can't hold more than Integer.MAX_VALUE elements. A LinkedList isn't limited in the same way, though, and can contain any amount of elements.
see the code below of arraylist default it is 10 when u create List l = new ArrayList();
public class ArrayList<E> extends AbstractList<E> implements List<E>,
Cloneable, Serializable, RandomAccess {
private static final long serialVersionUID = 8683452581122892189L;
private transient int firstIndex;
private transient int lastIndex;
private transient E[] array;
/**
* Constructs a new instance of {@code ArrayList} with ten capacity.
*/
public ArrayList() {
this(10);
}