//方法一: Integer[] arr= {1,2,3}; List<Integer> list = Arrays.asList(arr); if (list.contains(1)&&list.contains(2)){ System.out.println("1,2"); } //方法二: String[] arr = {"a","b","c"}; List<String> list = new ArrayList<String>(); Collections.addAll(list, arr); if (list.contains("a")&&list.contains("b")){ System.out.println("a,b"); }
时间: 2024-10-22 14:05:44