import org.apache.commons.lang3.ArrayUtils; /** * * @ClassName: RemoveSingleChartUtil * @Description: TODO(移除單個字符id工具類) * @author 學渣要逆襲 * */ public class RemoveSingleChartUtil { // 匹配ID而且刪除 public static String[] resultArray(String[] array, String compareId) { if (array.length == 1) { if (array[0].equals(compareId)) { array = (String[]) ArrayUtils.remove(array, 0); } } else { for (int i = 0; i < array.length;) { if (array[i].equals(compareId)) { if (array.length >= 1) { array = (String[]) ArrayUtils.remove(array, i); } i = 0; } else { ++i; } } } return array; } }