Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java Shuffling Using shuffle()

import java.util.ArrayList;
import java.util.Collections;
class Main {
    public static void main(String[] args) {
        // Creating an array list
        ArrayList<Integer> numbers = new ArrayList<>();
        // Add elements
        numbers.add(1);
        numbers.add(2);
        numbers.add(3);
        System.out.println("Sorted ArrayList: " + numbers);

        // Using the shuffle() method
        Collections.shuffle(numbers);
        System.out.println("ArrayList using shuffle: " + numbers);

    }
}
 
PREVIOUS NEXT
Tagged: #Java #Shuffling #Using
ADD COMMENT
Topic
Name
4+8 =