public static void main(String[] args) {
String str = "";
str += (int)(Math.random()*9+1);
for(int i = 0; i < 7; i++){//更改这里 可以控制生成数字的位数
str += (int)(Math.random()*10);
}
int num = Integer.parseInt(str);
System.out.println(num);
}
http://blog.sohu.com/s/MTAyMjIxNjYy/300349452.html