Advertisement
JeffGrigg

Untitled

Mar 10th, 2018
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.09 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Random;
  3.  
  4. public class MillionNull {
  5.     private static final int ONE_MILLION = 1_000_000;
  6.     private static final int INNER_SIZE = 6;
  7.  
  8.     public static void main(String[] args) {
  9.         final ArrayList<ArrayList<Integer>> myArrayListVariable = getObjects();
  10.  
  11.         myArrayListVariable.forEach(innerList -> { if (innerList.indexOf(null) >= 0) System.out.println(myArrayListVariable.indexOf(innerList));});
  12.     }
  13.  
  14.     private static ArrayList<ArrayList<Integer>> getObjects() {
  15.         final ArrayList<ArrayList<Integer>> myArrayListVariable = new ArrayList<>(ONE_MILLION);
  16.         final Random random = new Random();
  17.         for (int idx1 = 0; idx1 < ONE_MILLION; ++idx1) {
  18.             final ArrayList<Integer> innerList = new ArrayList<>(INNER_SIZE);
  19.             for (int idx2 = 0; idx2 < INNER_SIZE; ++idx2) {
  20.  
  21.                 innerList.add(random.nextInt());
  22.             }
  23.             myArrayListVariable.add(innerList);
  24.         }
  25.         myArrayListVariable.get(ONE_MILLION / 2).set(3, null);
  26.         return myArrayListVariable;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement