首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

JAVA 生活 随即6 位 字母+数字

2012-09-12 
JAVA 生存 随即6 位 字母+数字/** * 0-9 ASC 48-57 * A-Z ASC 65-90 * a-z ASC 97-122 */package com.nuts

JAVA 生存 随即6 位 字母+数字

/** * 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 stubint []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));}}



热点排行