Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – Black Friday 2026 – NPI EA – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – before_post_content
announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

1. Overview

In this tutorial, we’ll learn how to convert a Queue object into a List in Java.

We’ll explain several popular ways of doing this along with their implementations, and we’ll end each section with a test case to test the respective implementation.

2. Ways to Convert Queue to List

In this section, we’ll cover different ways to convert the Queue to a List using standard Java classes and methods. We’re assuming a non-null queue for all examples.

2.1. Using the ArrayList Constructor

The ArrayList constructor provides the easiest and most common way to convert a Queue to an ArrayList.

The idea is to pass the Queue as a parameter to the ArrayList constructor:

List<String> list = new ArrayList<>(queue);

The constructor new ArrayList<>(queue) efficiently inserts all of the queue elements into the new ArrayList.

2.2. Using the addAll() Method

The addAll() method is another great option to consider if we want to convert a Queue to a List.

As the name implies, this method allows adding all elements in the specified collection to the List.

Now, let’s see the logic:

List<String> list = new ArrayList<>();
list.addAll(queue);

We create a new List named list and populate it with the elements of the queue using the addAll() method. The method then returns the resultant list.

2.3. Using the LinkedList Constructor

The LinkedList constructor provides the most common and easiest way to convert a Queue to a LinkedList.

Similar to the above example using the ArrayList constructor, we simply pass the Queue as a parameter to the LinkedList constructor:

LinkedList<String> list = new LinkedList<>(queue);

The constructor new LinkedList<>(queue) efficiently converts the queue elements into the new LinkedList.

2.4. Using Stream API

Java 8 comes with a lot of new features that help in enhancing our code. Among these features, we find the Stream API.

Let’s illustrate how to use the stream API to convert a Queue to a List:

List<String> list = queue.stream().collect(Collectors.toList());

We convert the queue to a List using the collect(Collectors.toList()) operation, which collects the elements of the stream into a new list and returns it. This approach leverages a concise and functional programming style with streams to perform the conversion.

2.5. Using Guava

Guava is a popular open-source library developed by Google that provides a wide range of utility classes and methods to simplify common programming tasks in Java.

Let’s use Guava to convert Queue to List:

List<String> list = Lists.newArrayList(queue);

Guava’s utility method Lists.newArrayList(queue) simplifies the process of creating a new list from the elements of a queue.

3. Conclusion

In this article, we saw various ways to convert Queue to List in Java. Whether we prefer the simplicity of LinkedList, the versatility of ArrayList, the elegance of Java 8 streams, or the power of Guava, understanding these techniques empowers us to handle data seamlessly in our Java projects. We can experiment with these approaches to find the one best suited to our requirements and coding style.

The code backing this article is available on GitHub. Once you're logged in as a Baeldung Pro Member, start learning and coding on the project.
Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – Black Friday 2026 – NPI EA – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW

Course – Black Friday 2026 – NPI – main – after_post_content

announcement - icon

Yes, we're now running our Black Friday Sale. All Courses are 33% off until 1st December, 2026 at 17:00 Romania time:

>> EXPLORE ACCESS NOW