Here you can find the source of remove(String[] target, String[] needRemoved)
public static String[] remove(String[] target, String[] needRemoved)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.List; public class Main { public static String[] remove(String[] target, String[] needRemoved) { if (target == null) { throw new RuntimeException("target array is null!"); }/*from ww w . j a v a2s. c om*/ if (isEmpty(needRemoved)) { return target; } String[] result = target; for (String needRemove : needRemoved) { result = remove(result, needRemove); } return result; } public static String[] remove(String[] target, String needRemove) { if (target == null) { throw new RuntimeException("target array is null!"); } if (needRemove == null) { return target; } int index = searchFirst(target, needRemove); if (index == -1) { return target; } else { String[] result = new String[target.length - 1]; System.arraycopy(target, 0, result, 0, index); System.arraycopy(target, index + 1, result, index, target.length - index - 1); return remove(result, needRemove); } } public static boolean isEmpty(String[] arg) { if (arg == null) { return true; } return arg.length == 0; } public static int searchFirst(String[] target, String key) { if (isEmpty(target) || key == null) { return -1; } for (int i = 0; i < target.length; i++) { if (key.equals(target[i])) { return i; } } return -1; } public static boolean equals(String[] fullSet, String[] subSet) { if (isEmpty(fullSet) && isEmpty(subSet)) { return true; } if (length(fullSet) != length(subSet)) { return false; } List<String> fullList = Arrays.asList(fullSet); List<String> subList = Arrays.asList(subSet); return fullList.containsAll(subList) && subList.containsAll(fullList); } public static int length(String[] strs) { if (isEmpty(strs)) { return 0; } return strs.length; } }