public static void main(String[] args) {
String number="151,155,158,159,156";
String mobile="151,155";
String[] array=mobile.split(",");
String[] nums=number.split(",");
String str="";
for (int i = 0; i < nums.length; i++) {
for (int j = i+1; j < array.length; j++) {
if(nums[i].equals(array[j])){
nums[i]= "";
System.out.println("num is ="+nums);
// break;
}
}
if(""!=nums[i]){
str +=","+nums[i];
}
}
str=str.substring(1, str.length());
System.out.println(str);
}
String number="151,155,158,159,156";
String mobile="151,155";
String[] array=mobile.split(",");
String[] nums=number.split(",");
String str="";
for (int i = 0; i < nums.length; i++) {
for (int j = i+1; j < array.length; j++) {
if(nums[i].equals(array[j])){
nums[i]= "";
System.out.println("num is ="+nums);
// break;
}
}
if(""!=nums[i]){
str +=","+nums[i];
}
}
str=str.substring(1, str.length());
System.out.println(str);
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26128332/viewspace-706597/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26128332/viewspace-706597/