您的位置:首页 > 编程语言 > Java开发

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: