Java list | Arraylist in java
In this blog we will learn Java List and ArrayList in Java. Different Different type of List and Commonly used methods.
Java list | Arraylist in java
List: List is an interface in java that’s implementation is given by ArrayList,LinkedList,Stack and Vector. List extends Collection interface.
Synatx for instantiate the List interface.
List <data-type> list1= new ArrayList();
List <data-type> list2 = new LinkedList();
List <data-type> list3 = new Vector();
List <data-type> list4 = new Stack();
Collection Interface Main Methods:
public boolean add(E e)
public boolean addAll(Collection<? extends E> c)
public boolean remove(Object element)
public boolean removeAll(Collection<?> c)
default boolean removeIf(Predicate<? super E> filter)
public void clear()
public int size()
public Object[] toArray()
default Stream<E> stream()