Java LinkedList Exercises, Practice & Solutions
Java Collection: LinkedList Exercises [26 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
LinkedList:
In Java, LinkedList is another implementation of the List interface provided by the Java Collections Framework. It's part of the java.util package. Unlike ArrayList, which is backed by an array, LinkedList is implemented as a doubly-linked list.
1. Write a Java program to append the specified element to the end of a linked list.
Click me to see the solution
2. Write a Java program to iterate through all elements in a linked list.
Click me to see the solution
3. Write a Java program to iterate through all elements in a linked list starting at the specified position.
Click me to see the solution
4. Write a Java program to iterate a linked list in reverse order.
Click me to see the solution
5. Write a Java program to insert the specified element at the specified position in the linked list.
Click me to see the solution
6. Write a Java program to insert elements into the linked list at the first and last positions.
Click me to see the solution
7. Write a Java program to insert the specified element at the front of a linked list.
Click me to see the solution
8. Write a Java program to insert the specified element at the end of a linked list.
Click me to see the solution
9. Write a Java program to insert some elements at the specified position into a linked list.
Click me to see the solution
10. Write a Java program to get the first and last occurrence of the specified elements in a linked list.
Click me to see the solution
11. Write a Java program to display elements and their positions in a linked list.
Click me to see the solution
12. Write a Java program to remove a specified element from a linked list.
Click me to see the solution
13. Write a Java program to remove the first and last elements from a linked list.
Click me to see the solution
14. Write a Java program to remove all elements from a linked list.
Click me to see the solution
15. Write a Java program that swaps two elements in a linked list.
Click me to see the solution
16. Write a Java program to shuffle elements in a linked list.
Click me to see the solution
17. Write a Java program to join two linked lists.
Click me to see the solution
18. Write a Java program to copy a linked list to another linked list.
Click me to see the solution
19. Write a Java program to remove and return the first element of a linked list.
Click me to see the solution
20. Write a Java program to retrieve, but not remove, the first element of a linked list.
Click me to see the solution
21. Write a Java program to retrieve, but not remove, the last element of a linked list.
Click me to see the solution
22. Write a Java program to check if a particular element exists in a linked list.
Click me to see the solution
23. Write a Java program to convert a linked list to an array list.
Click me to see the solution
24. Write a Java program to compare two linked lists.
Click me to see the solution
25. Write a Java program to check if a linked list is empty or not.
Click me to see the solution
26. Write a Java program to replace an element in a linked list.
Click me to see the solution
Java Practice online
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/java-exercises/collection/linked-list.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics