I am trying to do a shuffle program where I randomize a group of numbers and print them out so none repeat. I have the randomization right just not sure how to implement a users input with an array.
Thank you for any help.
p.s I am new to this community so anything I may do wrong as far as the way I post or anything of that nature please let me know.
import java.util.*; public class Shuffle { public static int[] RandomizeArray(int[] array){ Random rgen = new Random(); for (int i = 0; i<array.length; i++){ int randomPosition = rgen.nextInt(array.length); int temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; } return array; } public static void main(String [] args) { Scanner keyboard = new scanner(System.in); System.out.println("Enter number of tracks"); int n = keyboard.nextInt(); array[n] = RandomizeArray(n); System.out.println(array[n]); } }