java if string in arraylist of strings code example Example: java arraylist contains string boolean ans = arr.contains("geeks");