随机数组合 随机号码产生器
Java代码 public class RandomUtil {
2.
3. private static Random random = new Random();
4.
5.
6. public static String getRandomNumber(String[] range,int rangeLength,int length){
7. StringBuffer sb = new StringBuffer();
8. for(int i=0;i
9. sb.append(String.valueOf(range[random.nextInt(rangeLength)]));
10. }
11. return sb.toString();
12. }
13. public static void main(String[] args) {
14. String[] range = {"0","1","2","3","4","5","6","7","8","9"};
15. System.out.println(getRandomNumber(range, 10, 8));
16.
17. }
18.}
运行结果:
91373770
编辑推荐:
温馨提示:因考试政策、内容不断变化与调整,长理培训网站提供的以上信息仅供参考,如有异议,请考生以权威部门公布的内容为准! (责任编辑:长理培训)
点击加载更多评论>>