bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Data Structures
Java•Java Data Structures

Java List

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind Java List?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Order

Put the learning moves in the order that makes the concept easiest to apply.

The List interface is part of the Java Collections Framework and represents an ordered collection of elements.
Common List Methods
Java List Interface

Java List Interface

The List interface is part of the Java Collections Framework and represents an ordered collection of elements.

You can access elements by their index, add duplicates, and maintain the insertion order.

Since List is an interface, you cannot create a List object directly.

Instead, you use a class that implements the List interface, such as:

  • ArrayList - like a resizable array with fast random access
  • LinkedList - like a train of cars you can easily attach or remove

Tip

Use List when you care about order, you may have duplicates, and want to access elements by index.

Common List Methods

MethodDescription
add()Adds an element to the end of the list
get()Returns the element at the specified position
set()Replaces the element at the specified position
remove()Removes the element at the specified position
size()Returns the number of elements in the list

List vs. Array

ArrayList
Fixed sizeDynamic size
Faster performance for raw dataMore flexible and feature-rich
Not part of Collections FrameworkPart of the Collections Framework

In the next chapters, you will learn how to use ArrayList and LinkedList .

Previous

Java Collections Framework

Next

Java ArrayList