JAVA小程序之随机产生七位中奖号码

package cn.com.basicskill;

import java.util.Random;

public class WrapperTest {

	/**
	 * @author k1280000
	 */
	public static void main(String[] args) {

		//产生一个七位数的随机数
		String lastNum = "";
		int num;
		Random ran = new Random ();
		for(int i = 0; i<7;i++){
			num = ran.nextInt(10);
			lastNum += new Integer (num).toString(); 
		}
		System.out.print(lastNum);
		
	}

}


结果
8061277

你可能感兴趣的:(java)