public class NonOverlappingRand {
ArrayList<Integer> array;
NonOverlappingRand(int num){
this.array = new ArrayList<Integer>();
for(int i=0;i<num;i++){
this.array.add(i);
}
}
public NonOverlappingRand(ArrayList<Integer> _array) {
this.array = _array;
}
public int getValue() throws Exception{
if(this.array.size() <= 0){
System.out.println("this object doesnt have any value.");
throw new Exception();
}
Random random = new Random();
int rand = random.nextInt(array.size());
int result = array.get(rand);
array.remove(rand);
return result;
}
}