yetang307

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

开发验证码

package  com.itheima.test;

public class test3{

public static void main(string[] args){

char[] chs = char[52];

for(int i=0;i<chs.length;i++){

if(i<25){

char[i]=(char)(97*i);

}else{

char[i]=(char)(65*i-26);

}

}

String result ="";

Random r = new Random();

for(int i=0;i<4;i++){

int randomIndex = r.nextInt(chs.length);

result = result + chs[randomIndex];

result = result +number;

System.out.println(result);

}

}

数组元素的复制

package com.itheima.test;

public class test4{

public static void main(string[] args){

int[] arr={1,2,3,4,5};

int[] newArr = new int[arr.length];

for(int i=0;i<arr.length;i++){

newArr[i]=arr[i];

}

for(int i=0;i<newArr.;ength;i++){

System.out.println(newArr[i]);

}

}

}

posted on 2022-08-13 18:36  椰糖  阅读(27)  评论(0)    收藏  举报