Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thospfuller/59febccd6c2d4a97d9811a79d03293c8 to your computer and use it in GitHub Desktop.
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
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