Revise the method displayList in Listing so that it uses the list method toArray instead of methods getLength and getEntry.
LISTING A client of a class that implements ListInterface
public class ListClient{ public static void main(String[] args) { testList(); } // end main public static void testList() { ListInterfacerunnerList = new AList (); // runnerList has only methods in ListInterface runnerList.add("16"); // winner runnerList.add(" 4"); // second place runnerList.add("33"); // third place runnerList.add("27"); // fourth place displayList(runnerList); } // end testList public static void displayList(ListInterface list) { int numberOfEntries = list.getLength(); System.out.println("The list contains " + numberOfEntries + " entries, as follows:"); for (int position = 1; position <= numberOfEntries; position++) System.out.println(list.getEntry(position) + " is entry " + position); System.out.println(); } // end displayList} // end ListClientOutputThe list contains 4 entries, as follows:16 is entry 14 is entry 233 is entry 327 is entry 4
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.