Flash cards
Review the key moves
1/4
Core idea
What is the main idea behind Java How To - Shuffle an Array?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
1Quick choice
Which statement best captures the main point of this lesson?
2Fill blank
Complete the missing token from the example code.
___ java.util.Arrays;How To Shuffle an Array
Randomly change the order of elements in an array using Collections.shuffle() :
Example
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Main {
public static void main(String[] args) {
String[] fruits = {"Apple", "Banana", "Cherry", "Mango"};
List<String> list = Arrays.asList(fruits);
Collections.shuffle(list);
System.out.println(list);
}
}