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.
You might also like to view...
What is the name of the centralized location for accessibility settings that can make the computer more comfortable for you to use?
What will be an ideal response?
A one-variable data table can be built ________
A) either horizontally or vertically B) horizontally C) vertically D) in column A