数字加字母
public class RandomTest { public static void main(String[] args) { String[] beforeShuffle = new String[] { "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; List list = Arrays.asList(beforeShuffle); Collections.shuffle(list); StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.size(); i++) { sb.append(list.get(i)); } String afterShuffle = sb.toString(); String result = afterShuffle.substring(5, 9); System.out .print(result) ; }}
随机生成六位数字
public static String getSix(){ Random rad=new Random(); String result = rad.nextInt(1000000) +""; if(result.length()!=6){ return getSix(); } return result; }
java随机生成数字字母验证码
最新推荐文章于 2025-02-25 11:07:15 发布