随机生成9个电话号码

package com.bdqn;

import java.util.Random;

public class TelephooneNumber {
    public static void main(String[] args) {
        Random random = new Random();
        int[] nums = new int[10];
        for(int i = 0 ; i < 9; i++){
            System.out.print(1);
            for(int j = 0; j <10 ;j++){
                 if(j == 0){
                     nums[j] = random.nextInt(7)+3;
                     System.out.print(nums[j]);
                     continue;
                 }
                 nums[j] = random.nextInt(10);
                System.out.print(nums[j]);
            }
            System.out.println();
        }
    }
}

运行结果:

 

posted @ 2019-02-26 11:12  杨文祥  阅读(401)  评论(0)    收藏  举报