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;
- public static void main(String[] args) {
- final ArrayList<Object> myArrayListVariable = getObjects();
- System.out.println(myArrayListVariable.indexOf(null));
- }
- private static ArrayList<Object> getObjects() {
- final ArrayList<Object> myArrayListVariable = new ArrayList<>(ONE_MILLION);
- final Random random = new Random();
- for (int idx = 0; idx < ONE_MILLION; ++idx) {
- myArrayListVariable.add(random.nextInt());
- }
- myArrayListVariable.set(ONE_MILLION / 2, null);
- return myArrayListVariable;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement