import java.util.*;
public class text04{
public static void main(String[] args){
int[] a={4,5,2,3};
int[] b={4,6,7,8};
/*
int[] a= new int[6];
int[] b= new int[4];
Random r = new Random();
for(int i=0;i<a.length;i++){
a[i]=r.nextInt(100);
}
for(int j=0;j<b.length;j++){
b[j]=r.nextInt(100);
}
*/
int[] c= new int[a.length+b.length];
System.arraycopy(a,0,c,0,a.length);
System.arraycopy(b,0,c,a.length,b.length);
List <Integer> numList = new ArrayList<Integer>();
for(int k:c)
numList.add(k);
Set<Integer> numSet = new HashSet<Integer>();
numSet.addAll(numList);
System.out.println(numSet);
}
}
Set集合是无序的,不可能会排序的,排序要用排序算法来实现。并且不能用set来存储。