Here you can find the source of sizeEquals(Iterable
public static <T> boolean sizeEquals(Iterable<T> iterable, int expectedSize)
//package com.java2s; /*//from w w w. j a v a2 s . c o m * Copyright (c) Microsoft. All rights reserved. * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ import java.util.Iterator; public class Main { public static <T> boolean sizeEquals(Iterable<T> iterable, int expectedSize) { Iterator<T> iterator = iterable.iterator(); int currentSize = 0; while (iterator.hasNext()) { if (expectedSize > currentSize) { currentSize++; iterator.next(); continue; } else { return false; } } return true; } }