Java Array Remove remove(String[] initial, String... toExclude)

Here you can find the source of remove(String[] initial, String... toExclude)

Description

remove

License

Apache License

Declaration

public static String[] remove(String[] initial, String... toExclude) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    public static String[] remove(String[] initial, String... toExclude) {
        List<String> result = new ArrayList<String>();
        result.addAll(Arrays.asList(initial));
        result.removeAll(Arrays.asList(toExclude));
        return result.toArray(new String[result.size()]);
    }/*from  w ww  . j a  va2 s  . com*/

    public static int[] toArray(Collection<Integer> result) {
        int[] array = new int[result.size()];
        int index = 0;
        for (Integer month : result) {
            array[index++] = month;
        }
        return array;
    }
}

Related

  1. remove(boolean[] array, boolean value)
  2. remove(int[] a, int[] b)
  3. remove(String[] target, String[] needRemoved)
  4. remove(T[] a, int i)
  5. removeAll(E[] array, Object... toRemove)
  6. removeAll(T[] array, Collection toRemove)