Here you can find the source of loadElements(Scanner scan, int elementCount, int skipCount)
protected static ArrayList<Integer> loadElements(Scanner scan, int elementCount, int skipCount)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Scanner; public class Main { protected static ArrayList<Integer> loadElements(Scanner scan, int elementCount, int skipCount) { ArrayList<Integer> sequence; if (elementCount > 0) { sequence = new ArrayList<>(elementCount); } else {//w w w. ja v a2 s . co m sequence = new ArrayList<>(); } while (scan.hasNextInt() && skipCount-- != 0) { scan.nextInt(); } while (scan.hasNextInt() && elementCount-- != 0) { sequence.add(scan.nextInt()); } return sequence; } }