The author added a for loop to a LinkedListAdd method to iteratively add integer values from 0 to the parameter numItems minus 1 to a LinkedList. The code highlights where a for loop was added to populate the list inside the loop using the loop counter variable i rather than individual add calls. A startTime variable tracks method execution time.
Hi,I have added a loop for adding values to list. Highlighted the .pdf
1. Hi,
I have added a loop for adding values to list. Highlighted the code changes below.
public static LinkedList doLinkedListAdd(int numItems) {
System.out.print("doLinkedListAdd: ");
LinkedList list = new LinkedList<>();
long startTime = getTimestamp();
// TODO Write code that adds 0 through (numitems - 1)
// to list inside a loop
for(int i=0; i
Solution
Hi,
I have added a loop for adding values to list. Highlighted the code changes below.
public static LinkedList doLinkedListAdd(int numItems) {
System.out.print("doLinkedListAdd: ");
LinkedList list = new LinkedList<>();
long startTime = getTimestamp();
// TODO Write code that adds 0 through (numitems - 1)
// to list inside a loop
for(int i=0; i