我正在尝试编写代码以在不使用集合的情况下对数组进行混洗.
我的洗牌代码
金额
private double amounts[] = { 0, 0.01, 1000000, 25, 250000, 75, 50, 1000,
200, 100, 400000, 750, 5000, 750000, 500, 100000, 300, 75000, 800,
20, 300000, 10, 50, 750, 25, 5, 1 };
public void Shuffle(){
Random rgen = new Random();
for (int i=0; i > amounts.length; i++) {
int randomPosition = rgen.nextInt(amounts.length);
double temp = amounts[i];
amounts[i] = amounts[randomPosition];
amounts[randomPosition] = temp;
}
}
Run Code Online (Sandbox Code Playgroud)
启动它的代码
public void casesSetup() {
for (int i = 0; i < …Run Code Online (Sandbox Code Playgroud)