请问为什么r = random.nextInt(35)+1;还能得到0的值?
intarr[]=newint[5];booleanon_off=false;Randomrandom=newRandom();intr;publicvoidrandom...
int arr[] = new int[5];boolean on_off = false;Random random = new Random();int r;public void randomNumber() { for (int i = 0; i < arr.length; i++) { r = random.nextInt(35)+1; for (int j = 0; j < arr.length; j++) { if (r == arr[j]) { on_off = false; break; } else { on_off = true; } } if (on_off == true) { arr[i] = r; } } System.out.print(Arrays.toString(arr) + "\t"); }请问为什么我还能得到0的值呢?懵逼!!!求大神指点..
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询