Here you can find the source of containsNumber(Collection
public static boolean containsNumber(Collection<Number> collection, Number number)
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { public static boolean containsNumber(Collection<Number> collection, Number number) { Iterator<Number> iterator = collection.iterator(); while (iterator.hasNext()) { Number comparable = iterator.next(); if (comparable == null) return comparable == number; if (comparable.doubleValue() == number.doubleValue()) return true; }//from www.j a v a 2 s . c o m return false; } }