Here you can find the source of containsSame(Iterable> coll, Object obj)
public static boolean containsSame(Iterable<?> coll, Object obj)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007 DSource.org and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w.j a v a2 s. co m * Bruno Medeiros - initial implementation *******************************************************************************/ import java.util.Iterator; public class Main { /** @return whether given coll contains given obj * (obj must be the same as the one contained, not just equal). */ public static boolean containsSame(Iterable<?> coll, Object obj) { for (Iterator<?> iterator = coll.iterator(); iterator.hasNext();) { Object element = iterator.next(); if (element == obj) return true; } return false; } }