Java Create ArrayList using List Interface

Tags: ArrayList

In this Java core tutorial we learn how to create a new java.util.ArrayList object using the java.util.List interface.

How to create ArrayList using List interface in Java

In Java we have the ArrayList implements the List interface so that we can create a new ArrayList object and assign it to a List variable as the following example Java code.

CreateArrayListExample1.java

import java.util.ArrayList;
import java.util.List;

public class CreateArrayListExample1 {
    public static void main(String... args) {
        // Create ArrayList using List interface
        List<String> arrayListOfString = new ArrayList<>();

        arrayListOfString.add("Java Tutorials");
        arrayListOfString.add("Spring Boot Tutorials");
        arrayListOfString.add("Web Development Tutorials");

        System.out.println(arrayListOfString);
    }
}
The output as below.
[Java Tutorials, Spring Boot Tutorials, Web Development Tutorials]

Happy Coding 😊

Java Convert ArrayList to Array

Java Convert ArrayList to String

Java Convert ArrayList to Comma Separated String

Java Convert ArrayList to HashSet

Java Convert ArrayList to LinkedList

Convert Array to List in Java

Java Get Index of Minimum Value in ArrayList

How to use Java ArrayList with Examples

Java Create New Array with Class Type and Length

Java Convert Array to ArrayList

Java Insert Element to ArrayList at Specified Index

Java Get Minimum Value in ArrayList

How to Traverse ArrayList using Iterator in Java

How to Traverse ArrayList using for each loop in Java

How to Traverse ArrayList using forEach() method in Java

Java Add Element to ArrayList