Question: ListPrintStrings.java 1 package iteratorlistreverse; Iterators - printing strings Implement the function public static void printStrings (List strings) 3 import java.util.List; 4 import java.util.ListIterator; 5 6

 ListPrintStrings.java 1 package iteratorlistreverse; Iterators - printing strings Implement the function

ListPrintStrings.java 1 package iteratorlistreverse; Iterators - printing strings Implement the function public static void printStrings (List strings) 3 import java.util.List; 4 import java.util.ListIterator; 5 6 public class ListPrintStrings { 7 /** 8 * Prints the given list of strings to System.out, skipping every second 9 string. Then, prints the list of strings in reverse order, skipping 10 every second string. All output should be printed on the same line. 11 12 * For example, if the list of strings is ["a", "b", "c", "d"], the output 13 * should be "acdb". If the list of strings is ["a", "b", "c"], the output 14 should be "acca". 15 16 @param strings strings to print 17 */ 18 public static void printStrings (List strings) { 19 // write your code here 20 } 21 } 22 in the manner described by the Javadoc. You must use a single iterator, specifically a ListIterator. That is, you must use the same ListIterator instance for iterating forwards through the list and iterating backwards. Important: Note that you should be using System.out.print() for this question. Not System.out.println(). This is why the Javadoc comment says "All output should be printed on the same line". Using System.out.println() adds a newline character which will cause the output to be more than one line, and cause the unit tests to fail

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!