Java Collection Split split(Collection d, int n)

Here you can find the source of split(Collection d, int n)

Description

split

License

Open Source License

Declaration

public static <T> Collection<? extends T> split(Collection<? extends T> d, int n) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static <T> Collection<? extends T> split(Collection<? extends T> d, int n) {
        Collection<T> tmp = new ArrayList<>();
        Iterator it = d.iterator();
        int k = Math.max(0, n);
        while (it.hasNext() && k > 0) {
            tmp.add((T) it.next());/*from w ww . j a  va  2  s . c  om*/
            k--;
        }
        return tmp;
    }
}

Related

  1. fastSplit(final Collection result, final String text, final char separator)
  2. getCollectionStringBySplit(Collection collection, String split)
  3. getStringCollection(String str, String split)
  4. getSymbolSplitString(Collection collection, String symbol)
  5. split(Collection collections, String separator)
  6. split(Collection orig, int batchSize)
  7. split(Collection set, int n)
  8. split(final Collection collection)