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); } }
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧
本文標(biāo)題:Java生成驗(yàn)證碼(黑馬程序員練習(xí)題4)大小寫帶隨機(jī)位置數(shù)字-創(chuàng)新互聯(lián)
URL地址:http://jinyejixie.com/article48/cccpep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計、建站公司、營銷型網(wǎng)站建設(shè)、微信小程序、Google、靜態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容