- /**
- * 0-9 ASC 48-57
- * A-Z ASC 65-90
- * a-z ASC 97-122
- */
- package com.nutsbling.rand;
- import java.util.Random;
- public class RandNumCharacter {
- /**
- *
- * @param begin 区间段的最小集合
- * @param end 区间段的最大集合
- * @return
- */
- public static int iRandom(int []begin, int []end){
- Random r =new Random();
- int index = r.nextInt(begin.length);
- int size = end[index]-begin[index];
- return r.nextInt(size)+begin[index]; //产生随机数后的ASC
- }
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int []begin={48,65,97};
- int []end={57,90,122};
- char []c = new char[6];
- for(int i=0;i<6;i++){
- c[i]=(char) iRandom(begin, end);
- }
- System.out.println(new String(c));
- }
- }
JAVA 生存 随即6 位 字母+数字
最新推荐文章于 2023-07-18 18:00:31 发布