ArrayList.add(E e) has the following syntax.
public boolean add(E e)
In the following code shows how to use ArrayList.add(E e) method.
//from w w w .jav a 2s. co m import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<Integer> arrlist = new ArrayList<Integer> (5); arrlist.add(15); arrlist.add(20); arrlist.add(25); System.out.println(arrlist); } }
The code above generates the following result.