Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Random;
- public class MillionNull {
- private static final int ONE_MILLION = 1_000_000;
- private static final int INNER_SIZE = 6;
- public static void main(String[] args) {
- final ArrayList<ArrayList<Integer>> myArrayListVariable = getObjects();
- myArrayListVariable.forEach(innerList -> { if (innerList.indexOf(null) >= 0) System.out.println(myArrayListVariable.indexOf(innerList));});
- }
- private static ArrayList<ArrayList<Integer>> getObjects() {
- final ArrayList<ArrayList<Integer>> myArrayListVariable = new ArrayList<>(ONE_MILLION);
- final Random random = new Random();
- for (int idx1 = 0; idx1 < ONE_MILLION; ++idx1) {
- final ArrayList<Integer> innerList = new ArrayList<>(INNER_SIZE);
- for (int idx2 = 0; idx2 < INNER_SIZE; ++idx2) {
- innerList.add(random.nextInt());
- }
- myArrayListVariable.add(innerList);
- }
- myArrayListVariable.get(ONE_MILLION / 2).set(3, null);
- return myArrayListVariable;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement