Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Mb to make an array with the numbers that fell out, then shuffle array?
import java.lang.Math;
import java.util.*;
public class SuperRandom
{
private ArrayList<Integer> numbers;
private Random rand;
public static void main(String[] args)
{
SuperRandom sr=new SuperRandom(10);
for(int i=0;i<10;i++)
System.out.print(sr.getValue());
}
public SuperRandom(int size){
rand=new Random();
numbers=new ArrayList<>();
for(int i=0;i<size;i++)
numbers.add(i);
}
public int getValue(){
int randomIndex=rand.nextInt(numbers.size());
return numbers.remove(randomIndex);
}
public int getSize(){
return numbers.size();
}
}
Create an array of 46 elements, fill with numbers, mix, then bite out of it one value at a time, as soon as the length becomes zero, refill the array well, or whatever it should be logically after the
upd. If Java is so godless about memory, then instead of biting out, you can have a separate incremental counter
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question