import java.util.Random; public class text_12 { public static void main(String[] args) { String a = "qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"; int[] c = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; char[] chars = a.toCharArray(); Random rm = new Random(); StringBuilder sb = new StringBuilder(); //int i = rm.nextInt(chars.length); //System.out.println(i); for (int i = 0; i< 4; i++) { int i1 = rm.nextInt(chars.length); char aChar = chars[i1]; sb.append(aChar); } int i3 = rm.nextInt(10); int i4 = c[i3]; char[] chars1 = sb.append(i4).toString().toCharArray(); //System.out.println(chars1); int i1 = rm.nextInt(2); char temp = chars1[i1]; chars1[i1] = chars1[chars1.length - 1]; chars1[chars1.length - 1] = temp; String result = new String(chars1); System.out.println(result); } }
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
本文标题:Java生成验证码(黑马程序员练习题4)大小写带随机位置数字-创新互联
URL地址:https://www.cdcxhl.com/article48/cccpep.html
成都网站建设公司_创新互联,为您提供网站设计、建站公司、营销型网站建设、微信小程序、Google、静态网站
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联