标签:
package lianxi; import java.util.*; public class Yanzhengma { public static void main(String[] args) { String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; int ary[]=new int[4]; for (int i = 0; i <4; i++) { Random r=new Random(); //一共62个元素,ary[i]取值为0-61,是各个元素的索引,ary[i]+1取值1-62,确保了62个数都可以随机到 ary[i]=r.nextInt(61); System.out.print(str.substring(ary[i],ary[i]+1)); } } }
标签:
原文地址:http://www.cnblogs.com/wenwen123/p/5487326.html