Find the difference set between two arrays
•
Java
import java.util.ArrayList;
public class array_diffrence {
public static void main(String[] args) {
ArrayList array1=new ArrayList();
ArrayList array2=new ArrayList();
array1.add("common1");
array1.add("common2");
array1.add("notcommon1");
array1.add("notcommon");
array2.add("common1");
array2.add("common2");
array2.add("notcommon2");
array2.add("notcommon3");
array2.removeAll(array1);
System.out.print("差集为:"+array2);
}
}
The output result is:
The difference set is: [notcommon2, notcommon3]
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
