1. 程式人生 > >生成count位隨機數工具類

生成count位隨機數工具類

工具類

import java.util.Random;

/**
 * 生成6位隨機數字
 */
public class GeneratorCode {

	/**
	 * 
	  * @Title: getCode
	  * @Description: 生成count個隨機數
	  * @param @param count
	  * @param @return    引數
	  * @return String    返回型別
	  * @throws
	 */
    public static String getCode(int count) {
        StringBuffer s = new StringBuffer();
        for (int i = 0; i < count; i++) {
            s.append(String.valueOf(new Random().nextInt(10)));
        }
        return s.toString();
    }
}