Here you can find the source of asList(Iterable
public static <T> List<T> asList(Iterable<T> iterable)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2012 Nikita Zhiltsov. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Public License v3.0 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/gpl.html//from w w w . j a v a 2s . c om * * Contributors: * Nikita Zhiltsov - initial API and implementation * Azat Khasanshin - implementation ******************************************************************************/ import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { public static <T> List<T> asList(Iterable<T> iterable) { List<T> list = new ArrayList<T>(); Iterator<T> it = iterable.iterator(); while (it.hasNext()) { T element = it.next(); if (element != null) { list.add(element); } } return list; } }