Here you can find the source of hasSameElement(List
private static boolean hasSameElement(List<Integer> firstList, List<Integer> secondList)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { private static boolean hasSameElement(List<Integer> firstList, List<Integer> secondList) { for (Integer element : firstList) { if (secondList.contains(element)) { return true; }//www.j a v a2 s. co m } return false; } }