随机生成11位的电话号码

import java.util.Random;

/**
 * Created by Administrator on 2017/5/25.
 */
public class Test {
    public static void main(String[] args) {
        for (int i = 0; i < 9; i++) {//9代表循环九次,产生九个随机号码
            String number = "139";//定义电话号码以139开头
            Random random = new Random();//定义random,产生随机数
            for (int j = 0; j < 8; j++) {
                //生成0~9 随机数
                number += random.nextInt(9);
            }
            System.out.println(number);//输出一个电话号码
        }
    }

}

运行结果:

13950035537 13966427550 13947766628 13916882701 13961332155 13937401011 13964507501 13901784558 13943250086

你可能感兴趣的:(JAVA)