Java代码
1.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<length;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
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交