Here you can find the source of contains(List> list, Object element, int begin, int end)
public static boolean contains(List<?> list, Object element, int begin, int end)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static boolean contains(List<?> list, Object element, int begin, int end) { return indexOf(list, element, begin, end) != -1; }// w w w . ja va 2 s. com public static boolean contains(List<?> list, Object element, int begin) { return contains(list, element, begin, list.size()); } public static int indexOf(List<?> list, Object element, int begin, int end) { begin = Math.min(begin, list.size()); end = Math.min(end, list.size()); if (begin == 0 && end == list.size()) return list.indexOf(element); for (int i = begin; i < end; i++) { if (Objects.equals(element, list.get(i))) return i; } return -1; } public static int indexOf(List<?> list, Object element, int begin) { return indexOf(list, element, begin, list.size()); } }