Topic: 此语句为何解?请帮助

  Print this page

1.此语句为何解?请帮助 Copy to clipboard
Posted by: mofeelsc
Posted on: 2004-12-09 14:56

public class MultiDimArray {
static Random rand = new Random();
static int pRand(int mod) {
return Math.abs(rand.nextInt()) % mod + 1; //此语句的大体意是为何?
}
//此语句的大体意是为何?
return Math.abs(rand.nextInt()) % mod + 1;
我能理解的是:取一个伪随机数的绝对值再取模再加1.
但加1这里不太清楚,为什么要加1加1和取模有什么用处要得到什么样的结果不得为知了。如果哪位大侠清楚请告之。

2.Re:此语句为何解?请帮助 [Re: mofeelsc] Copy to clipboard
Posted by: vainglory
Posted on: 2004-12-09 16:32

1mod10(mod-1)


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923