Skip to content
Learn Netverks

Lesson

Step 19/36 53% through track

arraylist

ArrayList

Last reviewed May 28, 2026 Content v20260528
Track mode
server_compiled
Means
Compiled runner
Reading
~1 min
Level
beginner

This lesson

This lesson teaches ArrayList: the syntax, APIs, and habits you need before advancing in Java.

Teams ship ArrayList on every Java codebase—skipping it leaves gaps in debugging and code reviews.

You will apply ArrayList in contexts like: In-memory models, caches, and DTO mapping in APIs and batch jobs.

Write Java with a public class (lessons use Main), click Run on server—the dev runner runs javac then java; fix compile errors from stderr (LEARNING_RUNNER_ENABLED=true).

When you can explain the previous lesson's ideas without copying starter code.

ArrayList<E> is a resizable array implementation of List—the default dynamic list in Java. Import from java.util.

Common operations

ArrayList<String> items = new ArrayList<>();
items.add("apple");
items.add("banana");
items.get(0);
items.size();
items.remove(0);

When to use

Ordered collections with indexed access and frequent append. For key lookup, use HashMap. For uniqueness, HashSet.

Important interview questions and answers

  1. Q: ArrayList vs LinkedList?
    A: ArrayList faster random access; LinkedList better for frequent insert/delete in the middle (rare in practice—ArrayList wins most cases).
  2. Q: Why generics?
    A: Compile-time type safety—no casting from raw lists.

Self-check

  1. Which method adds an element?
  2. What package contains ArrayList?

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • ArrayList vs array?
  • Remove while loop bug?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump