ArrayList

The Problem with Arrays. A Java array has a fixed length set when you create it. Once you write int[] a = new int[5];, the array can hold exactly five elements forever. If you need a sixth, you must allocate a brand new, larger array and copy every element acr

8 lessons, each with runnable code in the browser.

  1. Why ArrayList? Arrays vs ArrayList
  2. Adding and Accessing: add, get, size
  3. Modifying: set and remove
  4. Autoboxing and Wrapper Classes
  5. Traversing with the Enhanced For Loop
  6. Removing Elements During Traversal
  7. Standard Algorithms on ArrayList
  8. Putting It Together: Insertion Sort

Compilearn home