Write some code that will use an iterator to duplicate every item in an instance of StringLinkedListWithIterator in Listing 12.9. For example, if the list contains "a", "b", and "c", after the code runs, it will contain "a", "a", "b", "b", "c", and “c”.

What will be an ideal response?


```
// Make sure the iterator is at the front of the list
list.resetIteration();
while(list.moreToIterate()){
String data = list.getDataAtCurrent();
list.insertNodeAfterCurrent(data);
// Skip over the data just inserted and the next
list.goToNext();
list.goToNext();
}

System.out.println("Every value in the list should be”
+ “ repeated now");
list.showList();
```

This code is in StringLinkedIteratorFragments.java.

Computer Science & Information Technology

You might also like to view...

A ___________________ assessment attempts to identify what needs to be protected, what the pressures are against it, and how susceptible the current protection is.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Match the following terms to their meanings:

I. The value axis A compares two or more sets of data in one chart II. A single data series chart B. is a key that identifies the color, gradient, picture, texture, or pattern fill assigned to each data series in a chart III. A multiple data series chart C. displays incremental values to identify the values of the data series IV. A clustered column chart D. compares values for one set of data V. A legend E. groups or clusters similar data in columns to compare values across categories

Computer Science & Information Technology

Character entities end with a colon (:)

Indicate whether the statement is true or false

Computer Science & Information Technology

You can split the worksheet window into horizontal or vertical panes, but not both.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology