1// creating an Empty Integer ArrayList
2 ArrayList<Integer> arr = new ArrayList<Integer>(4);
3// using add() to initialize values
4// [1, 2, 3, 4]
5 arr.add(1);
6 arr.add(2);
7 arr.add(3);
8 arr.add(4);
9// use contains() to check if the element
10// 2 exits or not
11 boolean ans = arr.contains(2);