Question: Java Exercise In this assignment, you are to create a generic method called shuffleList(). The method is to take a parameter that can be an

Java Exercise

Java Exercise In this assignment, you are to create a generic method

In this assignment, you are to create a generic method called shuffleList(). The method is to take a parameter that can be an instance of any class implementing the List interface, and returns a new list where the entries of the original list have been randomly shuffled. The input list can be a list of any reference type. Sample Run List names = new ArrayList(); Collections.addAll(names, "Louisa", "Manuel", "Yo-jin", "Marcel"); System.out.println(names); shufflelist(names); System.out.println(names); System.out.println("---"); List numbers = new LinkedList(); Collections.addAll(numbers, new Double [] {1.1, 2.2, 3.3, 4.4, 5.5}); System.out.println(numbers); shuffleList(numbers); System.out.println(numbers); Output (up to randomness) [Louisa, Manuel, Yo-jin, Marcel] [Yo-jin, Manuel, Louisa, Marcel] [1.1, 2.2, 3.3, 4.4, 5.5] [5.5, 1.1, 4.4, 3.3, 2.2]

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!