JAVA随机数Random
2016-10-19 00:00
288 查看
/**
*
*
@author caryt
*
*/
public class test {
/**
*
@param args
*/
static int x[]=new int[15];
public static void main(String[] args) {
// TODO Auto-generated method stub
Random random=new Random();
int x = 0,y = -1;
do {
x=random.nextInt(10);//0~10;
y=random.nextInt(10);
System.out.println("x: "+x+" y: "+y);
}while (x!=y);
}
}
out: x: 2 y: 3
x: 0 y: 6
x: 8 y: 7
x: 4 y: 5
x: 8 y: 8
*
*
@author caryt
*
*/
public class test {
/**
*
@param args
*/
static int x[]=new int[15];
public static void main(String[] args) {
// TODO Auto-generated method stub
Random random=new Random();
int x = 0,y = -1;
do {
x=random.nextInt(10);//0~10;
y=random.nextInt(10);
System.out.println("x: "+x+" y: "+y);
}while (x!=y);
}
}
out: x: 2 y: 3
x: 0 y: 6
x: 8 y: 7
x: 4 y: 5
x: 8 y: 8
相关文章推荐
- java Random随机数
- java常用类解析十一:Random类(Math.random())生成指定范围的随机数或字符
- Java中的随机数生成器:Random,ThreadLocalRandom,SecureRandom
- Java 随机数生成 Random
- Java中生成随机数_Random()的用方法
- java中用来生成随机数的函数:Random()
- java java.uitl.Random产生随机数
- java Random 随机数
- java常用类解析十一:Random类(Math.random())生成指定范围的随机数或字符
- JAVA基础MATH类的应用(Random产生自己想要的范围类的随机数解决方案)
- java中的随机数Random
- java中的随机数产生方式,random()方法和Random类
- java中的随机数Random
- java产生随机数(Math.random())
- JAVA随机数Random
- java常用类解析十一:Random类(Math.random())生成指定范围的随机数或字符
- 随机数的困惑(java.util.Random/Math.Random()
- java中的随机数Random
- java 学习笔记 随机数产生的两种办法Math.random()和Random类
- Java中的随机数生成器:Random,ThreadLocalRandom,SecureRandom(转)