package com.kt.test; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class ArrayTest { public static void main(String[] args){ List<String> list = new ArrayList<String>(); String[] str1 = {"Java", "C++", "Php", "C#", "Python"}; String[] str2 = {"1", "C++", "2", "5", "Python"}; List list1= Arrays.asList(str1); List list2= Arrays.asList(str2); //方法一 /*for(int i = 0;i<list2.size();i++){ if(!list1.contains(list2.get(i))){ list.add((String) list2.get(i)); } }*/ //方法二 报错 for(int i=0;i<list1.size();i++){ if(list2.contains(list1.get(i))){ list2.remove(list1.get(i)); } } for(String a : list){ System.out.println("shuchu:"+a); } } }