展开全部
package com.zhiyou100.util;
import java.util.Random;
public class Picture {
public static void main(String[] args) {
Random ran=new Random();char ch[] =new char[]{'a','b','c','d','e','f','g','@','1','2','3','4','5'};
StringBuilder str=new StringBuilder("");
for(int i=0;i<4;i++){
str.append(ch[ran.nextInt(ch.length)]);
}
System.out.println("验证码="+str);
}}
在控制台上随机生成验证码
import java.util.Random;
public class Picture {
public static void main(String[] args) {
Random ran=new Random();char ch[] =new char[]{'a','b','c','d','e','f','g','@','1','2','3','4','5'};
StringBuilder str=new StringBuilder("");
for(int i=0;i<4;i++){
str.append(ch[ran.nextInt(ch.length)]);
}
System.out.println("验证码="+str);
}}
在控制台上随机生成验证码
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询