Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import java.util.Random; public class Main { public static List<Integer> randomChoose(int total, int selectedCount) { Random random = new Random(); List<Integer> resultList = new ArrayList<Integer>(); while (resultList.size() < selectedCount) { Integer randomNum = random.nextInt(total) + 1; if (!resultList.contains(randomNum)) { resultList.add(randomNum); } } return resultList; } }