import java.util.Random; int[] rand = new Random().ints(start, end).distinct().limit(number).toArray();