Question: The following function is supposed to take a list and return a copy of the list with the order of the elements reversed. However, it

 The following function is supposed to take a list and return

The following function is supposed to take a list and return a copy of the list with the order of the elements reversed. However, it doesn't work as intended. Point out the problems, and explain how to fix them. public static List reverse (List 1st) { List rev; if (1st instanceof ArrayList){ rev = new ArrayListO: } else { rev - new Linkedlist(); } Iterator it - lst.list Iterator(1st.size()-1); while (it.hasPrevious()) { rev.add(1, it previous()); } return rev; }

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!