자바로 인증번호 만들기 숫자만 (6자리)
String total="";
int num;
/* Random ran=new Random(); */
for(int i=0;i<6;i++){
num =(int)(Math.random()*9)+1;
total+=num;
}
자바로 인증번호 만들기 숫자_문자
StringBuffer make = new StringBuffer();
Random rd=new Random();
int w =0;
while(w<10) {
int a =rd.nextInt(3);
switch(a) {
case 0:
make.append((char)(rd.nextInt(26)+97)); //소문자 a~z
break;
case 1:
make.append((char)(rd.nextInt(26)+65)); //대문자 A~Z
break;
case 2:
make.append((rd.nextInt(10)));//숫자
break;
}
w++;
}
String key =make.toString();
System.out.println(key);
728x90
'JAVA > JavaScript' 카테고리의 다른 글
JavaScript 영문/숫자 조합 정규식 (영문+숫자 필수) (1) | 2023.01.16 |
---|---|
FAQ 페이지 클릭 / 넌클릭 아코디언 코드 (0) | 2022.12.16 |
체크박스 전체 선택 / 전체 해제 자바스크립트로만 (0) | 2022.08.22 |
실시간 데이터 변경 setTimeout (0) | 2022.08.01 |
setAttribute (클래스, 값 2개 넣기) (0) | 2022.08.01 |
댓글