JAVA隨機數Random

/**
 * 
 * @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);dom

}spa

}.net

out: x: 2 y: 3
x: 0 y: 6
x: 8 y: 7
x: 4 y: 5
x: 8 y: 8get

相關文章
相關標籤/搜索