Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import java.util.Random; public class Main { public static int[] getMachineSelectionNumNo(int size, int numbers[]) { int length = numbers.length; int num[] = new int[size]; Random random = new Random(); List<Integer> list = new ArrayList<Integer>(); while (list.size() < size) { int number = numbers[random.nextInt(length)]; list.add(number); } for (int i = 0; i < list.size(); i++) { num[i] = list.get(i); } return num; } }