java contains in arraylist code example Example: list contains List arr = new ArrayList(4); boolean ans = arr.contains(2);