随机数修改

back_recharge
lvxinran 2019-07-12 13:33:56 +08:00
parent 24eca20b07
commit 6fb6390d60
1 changed files with 3 additions and 3 deletions

View File

@ -25,7 +25,7 @@ public class MathUtils {
public static void main(String [] args){ public static void main(String [] args){
for (int i = 0 ; i <100;i++){ 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) { public static int randomForStrArray(String [] rateArray) {
@ -169,8 +169,8 @@ public class MathUtils {
return result; return result;
} }
public static int randomFromArray(int[] array){ public static int randomFromArray(int[] array){
if(array.length>1){ if(array.length>0){
return array[randomInt(array.length-1)]; return array[(int) Math.floor(Math.random()*array.length)];
} }
return 0; return 0;
} }