-1

I need to randomly shuffle an array of 10 names:

String[] names={"name 1", "name 2", "name 3", "name 4", "name 5", "name 6", "name 7", "name 8", "name 9", "name 10"};

What function could i use to solve this?

MOON
  • 1
  • 1
  • 1
    Please take the time to search for your answer on both this site and the net in general before posting a question. Duplicates only serve to make finding the correct answer more difficult. – MarsAtomic Mar 03 '23 at 02:22

1 Answers1

0

You can use Arrays.asList to create a List backed by the original array, then call Collections.shuffle.

Collections.shuffle(Arrays.asList(names));
Unmitigated
  • 76,500
  • 11
  • 62
  • 80