使用for循环和get方法遍历链表。
LinkedList<Integer> list = new LinkedList<>();// 添加元素for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i));}使用迭代器遍历链表。LinkedList<Integer> list = new LinkedList<>();// 添加元素Iterator<Integer> iterator = list.iterator();while (iterator.hasNext()) { System.out.println(iterator.next());}使用for-each循环遍历链表。LinkedList<Integer> list = new LinkedList<>();// 添加元素for (Integer value : list) { System.out.println(value);}使用Lambda表达式遍历链表。LinkedList<Integer> list = new LinkedList<>();// 添加元素list.forEach(System.out::println);使用Stream API遍历链表。LinkedList<Integer> list = new LinkedList<>();// 添加元素list.stream().forEach(System.out::println); 
