Java Iterator from getSomeElements(Iterator iterator, int limit)

Here you can find the source of getSomeElements(Iterator iterator, int limit)

Description

get Some Elements

License

Open Source License

Declaration

public static <T> List<T> getSomeElements(Iterator<T> iterator, int limit) 

Method Source Code


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

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Main {
    public static <T> List<T> getSomeElements(Iterator<T> iterator, int limit) {
        ArrayList<T> list = new ArrayList<>();
        int currentAmount = 0;
        while (iterator.hasNext() && (currentAmount++ < limit)) {
            list.add(iterator.next());/*from   ww w.java  2s  .  c o m*/
        }
        return list;
    }
}

Related

  1. getList(Iterator iterator)
  2. getMaxLength(Iterator i)
  3. getPerplexity(Iterator probStream)
  4. getPersistentKeysIterator(HashMap hashMap)
  5. getSigLinePastOtherAnnotations(String selfCmprurrentLine, Iterator line_itr)
  6. getSubList(Iterator iterator, int startIndex, int numberOfItems)
  7. getTypedIterator(Iterator it, Class clz)
  8. toIterator(Enumeration enumeration)