如何把2个String[]相减
我有2个String[]
String1[1,2,3,4,5]
String2[1,5]
我怎么让String1减去String2最后得到String[2,3,4]???
[解决办法]
String[] ss1 ={"1","2","3","4","5"};
String[] ss2 ={"1","5"};
List<String> ls=new ArrayList<String>();
for(String s1 : ss1){
boolean flag = false;
for(String s2 : ss2){
if(s1.equals(s2)){
flag =true;
}
}
if(flag==false){
ls.add(s1);
}
}
String[] ss3 = ls.toArray(new String[ls.size()]);
for(String s3 : ss3){
System.out.println(s3);
}