Grokking Java Interview Questions
Vote

0% completed

​

ArrayList Internals and Growth

List<Integer> orders = new ArrayList<>(); for (int id = 1001; id <= 1010; id++) orders.add(id); orders.add(1011);

The first two lines store ten order ids of an online grocery store, and the third line adds one more. The third line looks the same as the ten calls before it, but it does much more work. Java creates a second array, copies ten references into it, and stops using the first array.

The four questions below explain that extra work. They cover what an `ArrayList

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content