1import java.util.LinkedList;
2LinkedList<Integer> myList = new LinkedList<Integer>();
3myList.add(0);
4myList.remove(0);//Remove at index 0
5myList.size();
6myList.get(0);//Return element at index 0
1// Java program to iterate the elements
2// in an LinkedList
3
4import java.util.*;
5
6public class GFG {
7
8 public static void main(String args[])
9 {
10 LinkedList<String> ll
11 = new LinkedList<>();
12
13 ll.add("Geeks");
14 ll.add("Geeks");
15 ll.add(1, "For");
16
17 // Using the Get method and the
18 // for loop
19 for (int i = 0; i < ll.size(); i++) {
20
21 System.out.print(ll.get(i) + " ");
22 }
23
24 System.out.println();
25
26 // Using the for each loop
27 for (String str : ll)
28 System.out.print(str + " ");
29 }
30}