Lesson 16 of 34
ArrayList: A List That Grows
9 min 30 XP
An array has a fixed size. When you don't know how many items you'll have, use an ArrayList, which grows by itself. Write Integer instead of int and Double instead of double inside the < >.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.Array: arr.length (no brackets). String: s.length(). ArrayList: list.size(). Don't mix these three up in an interview!