16.6.2 LinkedList
Figure 16.3 demonstrates various operations on LinkedLists. The program creates two LinkedLists of Strings. The elements of one List are added to the other. Then all the Strings are converted to uppercase, and a range of elements is deleted.
Click here to view code image
1 // Fig. 16.3: ListTest.java 2 // Lists, LinkedLists and ListIterators. 3 import java.util.List; 4 import java.util.LinkedList; 5 import java.util.ListIterator; 6
7 public class ListTest 8 { 9 public static void main(String[] args)10 {11 // add colors elements to list112 String[] colors =13 {"black", "yellow", "green", "blue", "violet", "silver"};14 List<String> list1 = new LinkedList<>();15