随机数修改
parent
24eca20b07
commit
6fb6390d60
|
|
@ -25,7 +25,7 @@ public class MathUtils {
|
|||
|
||||
public static void main(String [] args){
|
||||
for (int i = 0 ; i <100;i++){
|
||||
System.out.println(randomInt(10));
|
||||
System.out.println(randomFromArray(new int[]{100}));
|
||||
}
|
||||
}
|
||||
public static int randomForStrArray(String [] rateArray) {
|
||||
|
|
@ -169,8 +169,8 @@ public class MathUtils {
|
|||
return result;
|
||||
}
|
||||
public static int randomFromArray(int[] array){
|
||||
if(array.length>1){
|
||||
return array[randomInt(array.length-1)];
|
||||
if(array.length>0){
|
||||
return array[(int) Math.floor(Math.random()*array.length)];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue