CodeToConcept
About

java

java Tutorials

Introduction
Java Variables
Java Data Types
Java Type Casting
Java Operators
Java Input/Output
Java Class & Object
java Method
Java Constructor
Java this keyword
Java super keyword
Java Method Overloading and Overriding
Java Interface
Java Abstract Class
Java Memory Management
Design Patterns
JDBC (Database Connectivity)
Java IDEs

java Tutorials

Introduction
Java Variables
Java Data Types
Java Type Casting
Java Operators
Java Input/Output
Java Class & Object
java Method
Java Constructor
Java this keyword
Java super keyword
Java Method Overloading and Overriding
Java Interface
Java Abstract Class
Java Memory Management
Design Patterns
JDBC (Database Connectivity)
Java IDEs

Sample Question

Think it through, then check the tutorial.

CodeToConcept

Quickly learn through simple, structured, and practical coding tutorials. Build your confidence from step zero to real-world experience.

© 2026 CodeToConcept. All rights reserved.

Quick Links

AboutTutorials

Tutorials

JavaHTMLCSS

Support

Privacy PolicyTerms of ServiceContact
GitHubTwitterYouTube

List in Java

List is a collection interface for an ordered sequence of elements. Every element has an index, starting at zero. A list can contain equal values more than once, and its order does not mean the values are automatically sorted.

Why Do We Need This?

A playlist may contain the same song twice and keep songs in the order selected by the listener. A list fits this kind of sequence because both position and repetition can matter.

Main Ideas

ConceptWhat it means
add(value)Adds a value when supported
get(index)Reads the value at a position
set(index, value)Replaces a value when supported
remove(index)Removes the value at a position when supported
ArrayList and LinkedListTwo implementations with different storage and operation costs

Simple Working Example

Run this program on its own. All required imports and classes are included.

import java.util.ArrayList;
import java.util.List;
 
public class HelloWorld {
    public static void main(String[] args) {
        List<String> lessons = new ArrayList<>();
        lessons.add("Arrays");
        lessons.add("Strings");
        lessons.add("Arrays");
        System.out.println(lessons);
        System.out.println("Second lesson: " + lessons.get(1));
        System.out.println("Size: " + lessons.size());
    }
}

Output

[Arrays, Strings, Arrays]
Second lesson: Strings
Size: 3

ArrayList keeps the insertion sequence here, including the repeated Arrays value. get(1) reads the second element. Not every List supports adding or removing elements; some lists are unmodifiable.

Topics in This Section

  • ArrayList
  • LinkedList
  • Vector
  • Stack

Easy Way to Remember

Choose a list when position and sequence matter. The next lessons cover ArrayList, LinkedList, and the older Vector and Stack classes.

See you in next page....??

← OverviewArrayList →
← OverviewArrayList →