- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Program to convert ArrayList to LinkedList in Java
Let’s say the following is our ArrayList −
List<String> arrList = Arrays.asList("John", "Jacob", "Kevin", "Katie", "Nathan");
Now, convert this ArrayList to LinkedList using toCollection() −
List<String> myList = arrList.stream().collect(Collectors.toCollection(LinkedList::new));
Example
Following is the program to convert ArrayList to LinkedList in Java −
import java.util.*; import java.util.stream.*; public class Demo { public static void main(String args[]) { List<String> arrList = Arrays.asList("John", "Jacob", "Kevin", "Katie", "Nathan"); System.out.println("ArrayList = " + arrList); List<String> myList = arrList.stream().collect(Collectors.toCollection(LinkedList::new)); System.out.println("LinkedList (ArrayList to LinkedList) = " + myList); } }
Output
ArrayList = [John, Jacob, Kevin, Katie, Nathan] LinkedList (ArrayList to LinkedList) = [John, Jacob, Kevin, Katie, Nathan]
- Related Articles
- Convert LinkedList to ArrayList in Java
- When to use LinkedList over ArrayList in Java
- How to convert LinkedList to Array in Java?
- Convert LinkedList to an array in Java
- Differences between ArrayList and LinkedList in Java
- How to remove an element from ArrayList or, LinkedList in Java?
- Java Program to Implement LinkedList
- Convert an ArrayList to HashSet in Java
- Java Program to Convert the LinkedList into an Array and vice versa
- Java Program to Convert the ArrayList into a string and vice versa
- What is the difference between ArrayList and LinkedList in Java?
- Java Program to Detect loop in a LinkedList
- Java Program to Add elements to a LinkedList
- How to convert Java array or ArrayList to JsonArray using Gson in Java?
- Java Program to Remove elements from the LinkedList

Advertisements