public static void main(String[] args) {
String[] stra = {"_zxl","2","3"};
String[] strb = {"_zxl","2","3"};
System.out.println(Arrays.toString(remDuplicate(stra , strb)));
}
public static Object[] remDuplicate(String[] stra,String [] strb){
String [] resStrArr = new String[stra.length+strb.length];
//浅复制A的数据
String[] temArr = Arrays.copyOf(stra, stra.length + strb.length);
// 数组的扩容
// src:源数组
// srcPos:在源数组中,开始复制的位置
// dest:目标数组
// destPos:在目标数组中,开始赋值的位置
// length:要复制的长度
//arraycopy(Object src, int srcPos,Object dest, int destPos,int length);
System.arraycopy(strb, 0, temArr, stra.length, strb.length);
System.out.println(Arrays.toString(temArr));
StringBuffer sb = new StringBuffer();
String patter = "_zxl";
int i = 0;
for(String str :temArr){
if(sb.indexOf(str+patter)==-1){
sb.append(str+"_zxl,");
resStrArr[i]=str;
i++;
}
}
String [] resArr = new String[i];
System.arraycopy(resStrArr, 0, resArr, 0, i);
return resArr;
}