Problem

Revise the method displayList in Listing so that it uses the list method toArray instead o...

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()  {  ListInterface runnerList = 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

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 12
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT