[Java] 纯文本查看 复制代码
import java.util.Random;
class Demo02{
public static void main(String[] args){
int[] arr1 = new int[10];
int[] arr2 = new int[10];
//创建Random对象
Random r = new Random();
for(int f = 0 ; f < arr1.length ; f ++){
arr1[f] = r.nextInt(100)+1 ;
if(f>1){
for( int i = 0 ; i< arr1.length-1 ; i++){
for(int j = i+1 ; j < arr1.length ; j++){
if(arr1 == arr1[j]){
arr1 = r.nextInt(100)+1 ;
break ;
}
}
}
}
}
for( int i = 0 ; i< arr1.length ; i++){
System.out.print(arr1+",");
}
for(int f = 0 ; f < arr2.length ; f ++){
arr2[f] = r.nextInt(100)+1 ;
if(f>1){
for(int k = 0 ; k< arr2.length ; k++){
for(int j = k+1 ; j < arr2.length ; j++){
if(arr2[k] == arr2[j]){
arr2[k] = r.nextInt(100)+1 ;
break ;
}
}
}
}
}
System.out.println("换行");
for(int i = 0 ; i< arr2.length ; i++){
System.out.print(arr2+",");
}
method(arr1,arr2);
}
public static void method(int[] arr1 , int[] arr2){
StringBuilder b = new StringBuilder();
for(int j = 0 ; j< arr2.length ; j ++){
b.append(arr2[j]);
}
String str = b.toString();
for(int i = 0; i < arr1.length ; i ++){
String s = String.valueOf(arr1);
if(!(str.contains(s))){
b.append(arr1);
}
}
String str2 = b.toString();
System.out.println("字符串长度为:"+str2.length());
for(int i = 0 ; i<str2.length() ;i++){
System.out.print(str2.charAt(i));
}
}
}