List in Java

Just like shopping list

Class Diagram (click to zoom)

read more here

imports

import java.util.List;
import java.util.ArrayList;

Array List

Array List is one of the inbuilt data structures in Java. It is a dynamic array (where the size of the data structure not needed to be declared first) for storing elements (Objects).

Creating a List

If you try to add something to the lists above you will get a NullPointerException, because strings and doubles, both equal null!

Positional Access Operations

Iterating over the List

To add an element

To remove

  • Removing elements from list B that are present in the list A

Last updated

Was this helpful?