Java Collection Create createCollection( final Iterable object)

Here you can find the source of createCollection( final Iterable object)

Description

create Collection

License

Apache License

Declaration

public static <T> Collection<T> createCollection(
            final Iterable<T> object) 

Method Source Code

//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.util.ArrayList;
import java.util.Collection;

import java.util.Iterator;

public class Main {
    public static <T> Collection<T> createCollection(
            final Iterable<T> object) {
        final Collection<T> collection = new ArrayList<T>();
        for (final T item : object) {
            collection.add(item);/* ww w.ja v a2  s.c  om*/
        }
        return collection;
    }

    public static <T> Collection<T> createCollection(
            final Iterator<T> iterator) {
        final Collection<T> collection = new ArrayList<T>();
        while (iterator.hasNext()) {
            collection.add(iterator.next());
        }
        return collection;
    }
}

Related

  1. create(Collection coll)
  2. createAuthorString(Collection users)
  3. createCollection(Collection col)
  4. createCollection(Object[] objects)
  5. createCollection(T... items)
  6. createCollection(X o)