ArrayList<Integer> myArrayList = new ArrayList<Integer>();
Creating a ArrayList is a bit different as compared to Creating an Array. Since ArrayList can only hold Object data, While creating the ArrayList we are denoting the compiler that this ArrayList will contain Integer data.
Let's look into various utility methods provided in ArrayList Class which we can utilise.
Adding an Element into ArrayList
ArrayList myArrayList = new ArrayList(); myArrayList.add(10);
Removing an Element from ArrayListArrayList myArrayList = new ArrayList(); myArrayList.add(10); myArrayList.remove(10);
Check if ArrayList contains specific elementArrayList myArrayList = new ArrayList(); myArrayList.add(10); myArrayList.contains(10);