package com.hanqi; import java.util.*; public class yanzhengma { public static void main(String[] args) { // TODO 自动生成的方法存根 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)); } } }
时间: 2024-10-09 22:30:49