Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started