J.5.2. LinkedList
Figure J.3 demonstrates various operations on LinkedList
s. The program creates two LinkedList
s of String
s. The elements of one List
are added to the other. Then all the String
s are converted to uppercase, and a range of elements is deleted.
1 // Fig. J.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< String ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.