Created
December 5, 2023 20:13
-
-
Save thospfuller/59febccd6c2d4a97d9811a79d03293c8 to your computer and use it in GitHub Desktop.
Use the add and addAll methods to insert elements into a Linked List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.LinkedList; | |
import java.util.List; | |
public class Main { | |
public static void main(String[] args) { | |
String[] values = { | |
"Apples", | |
"Pears", | |
"Bananas", | |
"Grapes", | |
"Peaches", | |
"Strawberries" | |
}; | |
List<String> valueList = Arrays.asList(values); | |
List<String> exampleList = new LinkedList<>(); | |
exampleList.addAll(valueList); | |
System.out.println ("exampleList: " + exampleList); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment