当前位置: 技术问答>java相关
如何在APPLET中随机产生3中大小不同的小球?
来源: 互联网 发布时间:2015-06-07
本文导语: 图片可以自己制作。谢谢! | 随机数可以用 java.util.Random 实现 Random.nextInt(int n); 分别得到球的四个不同参数 然后分别画出来就行了 //-------------- 关于 nextInt ------------------------ nextInt public...
图片可以自己制作。谢谢!
|
随机数可以用 java.util.Random 实现
Random.nextInt(int n);
分别得到球的四个不同参数
然后分别画出来就行了
//-------------- 关于 nextInt ------------------------
nextInt
public int nextInt(int n)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. The general contract of nextInt is that one int value in the specified range is pseudorandomly generated and returned. All n possible int values are produced with (approximately) equal probability. The method nextInt(int n) is implemented by class Random as follows:
public int nextInt(int n) {
if (n> 31);
int bits, val;
do {
bits = next(31);
val = bits % n;
} while(bits - val + (n-1)
Random.nextInt(int n);
分别得到球的四个不同参数
然后分别画出来就行了
//-------------- 关于 nextInt ------------------------
nextInt
public int nextInt(int n)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. The general contract of nextInt is that one int value in the specified range is pseudorandomly generated and returned. All n possible int values are produced with (approximately) equal probability. The method nextInt(int n) is implemented by class Random as follows:
public int nextInt(int n) {
if (n> 31);
int bits, val;
do {
bits = next(31);
val = bits % n;
} while(bits - val + (n-1)
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。