十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
//交集
公司主营业务:网站建设、成都网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出微山免费做网站回馈大家。
String []a={"1","2","3","4","7","8"};
String []b={"1","2","5","6","9","8"};
for(int i=0;ia.length;i++){
for(int j=i;jb.length;j++){
if(a[i]==b[j]){
System.out.print(b[j]);
}
}
}
}
public static void main(String[] args) {
Integer[] A = {1,2,3,4};
Integer[] B = {1,3,7,9,11};
ListInteger listA = Arrays.asList(A);
ListInteger listB = Arrays.asList(B);
ListInteger jiaoji = new ArrayListInteger();
for(Integer a:listA){
if(listB.contains(a)){
jiaoji.add(a);
}
}
System.out.println(jiaoji);
ListInteger bingji = new ArrayListInteger();
for(Integer a:listA){
if(!bingji.contains(a)){
bingji.add(a);
}
}
for(Integer b:listB){
if(!bingji.contains(b)){
bingji.add(b);
}
}
System.out.println(bingji);
ListInteger chaji = new ArrayListInteger();
for(Integer a:listA){
if(!listB.contains(a)){
chaji.add(a);
}
}
System.out.println(chaji);
}
import java.util.ArrayList;
import java.util.List;
public class strSplit {
public static void main(String args[])
{
ListString list1 = new ArrayListString();
ListString list2 = new ArrayListString();
list1.add("g");
list1.add("s");
list1.add("a");
list1.add("f");
list2.add("g");
list2.add("c");
list2.add("b");
list2.add("a");
//取交集
list1.retainAll(list2);
System.out.print(list1);
//取补集
//list1.removeall(list2);
// System.out.print(list1);
}
}
public static void main(String[] args) {
SetCharacter result = new HashSetCharacter();
SetCharacter set1 = new HashSetCharacter() {
{
add('a');
add('b');
add('c');
add('d');
add('e');
}
};
SetCharacter set2 = new HashSetCharacter() {
{
add('a');
add('b');
add('c');
}
};
result.clear();
result.addAll(set1);
result.retainAll(set2);
System.out.println("交集:" + result);
result.clear();
result.addAll(set1);
result.removeAll(set2);
System.out.println("差集:" + result);
result.clear();
result.addAll(set1);
result.addAll(set2);
System.out.println("并集:" + result);
result.clear();
result.addAll(set1);
if(result.containsAll(set2)){
result.removeAll(set2);
System.out.println("补集:"+result);
}else{
System.out.println("无补集");
}
}
import java.util.Arrays; //Java中如何把两个数组合并为一个 public class gog { public static void main(String[] args) { String [] str1 = {"J","a","v","a","中"}; String [] str2 = {"如","何","把","两","个","数","组","合","并","为",...