补充一下:
import java.util.*;
public class Conversion
{
public static void main(String[] args) throws IOException
{
Random ri=new Random(100);
int i;
i=ri.nextInt();
System.out.print(i+" ");
}
}下面是我运行8次得到的结果:-1193959466 -1193959466 -1193959466 -1193959466 -1193959466 -1193959466 -1193959466 -1193959466
import java.util.*;
public class Conversion
{
public static void main(String[] args) throws IOException
{
Random ri=new Random(100);
int i;
i=ri.nextInt();
System.out.print(i+" ");
}
}下面是我运行8次得到的结果:-1193959466 -1193959466 -1193959466 -1193959466 -1193959466 -1193959466 -1193959466 -1193959466
解决方案 »
- 再次求助!关于byte数组截取的问题
- 数组边界超出问题
- Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError:Java heap space
- tomcat的"ctrl + c" 问题
- 同样是交换两数的问题
- 30分求教关于java中Timer的使用
- 令人费解的一段程序~~~!!!大侠求救啊!!!!
- float和double 类型不对?
- 请问怎么才能把panel放在Contener的确定位置?大虾帮忙啊!!!
- 求助:生活感情问题?让我捆饶难定?帮忙分析一下?
- 走过路过的朋友来看看!
- 使用Jbuilder7.0开发Web Application时,如何添加properties文件?
————————————————————————————
If two instances of <code>Random</code> are created with the same
* seed, and the same sequence of method calls is made for each, they
* will generate and return identical sequences of numbers.
————————————————————————————
public class password
{
static void main(String args[])
{
int int1
Random test=new Random();
for (int i=0;i<10;i++)
{
int1=Math.abs(test.nextInt())+100; System.out.print(int1); }
}
}
就知道了,那里就叫你写了一个Random类,他使用一个seed通过一顿
胡乱暴算,得出一个数,返回。
通常是你可以用系统时间等易变的变量做seed构造Random,
或者用Math的
这个和所有语言是一样的。======================
还好结果是对的 public static void main(String[] args) {
JRandom_Test JRandom_Test1 = new JRandom_Test(); double douRandom=0;
int intRandom=0;
System.out.println("Random Test");
for(int i=0;i<100;i++){
if(i%5==0){
System.out.print("\r\n"+(new Integer(i/5)).toString()+"\t");
}
douRandom=java.lang.Math.random()*100;
intRandom=(new Double(douRandom)).intValue();
System.out.print(intRandom);
System.out.print("\t"); }
================================================================
★★