3
2021/9/21 23:14:59
本文主要是介绍3,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
简单验证码生成程序
通过数组存储26个大写字母和26个小写字母和0-9数字
随机成0-61的4个数字对应数组下标
输出四位验证码。
package 验证码程序;
import java.util.Random;
public class Number {
public String []array= {"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","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","0","1","2","3","4","5","6","7","8","9"};
public int a,b,c,d;
public String creat() {
Random rand =new Random();
a=rand.nextInt(61) + 0;
b=rand.nextInt(61) + 0;
c=rand.nextInt(61) + 0;
d=rand.nextInt(61) + 0;
String e = array[a]+" "+array[b]+" "+array[c]+" "+array[d];
//System.out.println("验证码:");
//System.out.println(array[a]+" "+array[b]+" "+array[c]+" "+array[d]);
return e;
}
}
这篇关于3的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-25初学者必备:订单系统资料详解与实操教程
- 2024-12-24内网穿透资料入门教程
- 2024-12-24微服务资料入门指南
- 2024-12-24微信支付系统资料入门教程
- 2024-12-24微信支付资料详解:新手入门指南
- 2024-12-24Hbase资料:新手入门教程
- 2024-12-24Java部署资料
- 2024-12-24Java订单系统资料:新手入门教程
- 2024-12-24Java分布式资料入门教程
- 2024-12-24Java监控系统资料详解与入门教程