---
title: "How to create ArrayList in Java?"  
description: "How to create ArrayList in Java?"  
author: "Utpal Vishwas"  
published: 2023-07-21  
updated: 2023-07-22  
canonical: https://www.mindstick.com/forum/159212/how-to-create-arraylist-in-java  
category: "java"  
tags: ["java", "array", "array list"]  
reading_time: 2 minutes  

---

# How to create ArrayList in Java?

How to create [ArrayList](https://www.mindstick.com/articles/11973/arraylist-class-in-c-sharp) in [Java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming)?

## Replies

### Reply by Aryan Kumar

There are two ways to create an array list in Java:

- **Using the** `ArrayList()` **constructor.** The `ArrayList()` constructor creates an empty array list.

```plaintext
ArrayList<String> arrayList = new ArrayList<>();
```

- **Using the** `add()` **method.** The `add()` method adds an element to the end of the array list.

```plaintext
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("Hello");
```

Here is an example of how to create an array list and add some elements to it:

```plaintext
import java.util.ArrayList;

public class ArrayListExample {

  public static void main(String[] args) {
    // Create an empty array list
    ArrayList<String> arrayList = new ArrayList<>();

    // Add some elements to the array list
    arrayList.add("Hello");
    arrayList.add("World");

    // Print the array list
    System.out.println(arrayList);
  }
}
```

Output:

```plaintext
[Hello, World]
```

Here are some important things to note about creating array lists:

- Array lists are dynamic data structures, which means that they can grow or shrink as needed.
- Array lists are not synchronized, which means that they are not thread-safe.
- Array lists are implemented using a linked list, which means that they are not as efficient as arrays for storing large amounts of data.


---

Original Source: https://www.mindstick.com/forum/159212/how-to-create-arraylist-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
