Java Array Remove removeFromArray(String[] oldArray, String stringToRemove)

Here you can find the source of removeFromArray(String[] oldArray, String stringToRemove)

Description

remove From Array

License

BSD License

Declaration

public static String[] removeFromArray(String[] oldArray, String stringToRemove) 

Method Source Code


//package com.java2s;
/*L//from w  w  w .ja  v  a 2  s. c o m
 *  Copyright SAIC
 *  Copyright SAIC-Frederick
 *
 *  Distributed under the OSI-approved BSD 3-Clause License.
 *  See http://ncip.github.com/cananolab/LICENSE.txt for details.
 */

import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;

public class Main {
    public static String[] removeFromArray(String[] oldArray, String stringToRemove) {
        List<String> list = new ArrayList<String>(Arrays.asList(oldArray));
        list.remove(stringToRemove);
        return list.toArray(new String[0]);
    }
}

Related

  1. removeFirstTwoArgs(String[] args, int startIndex)
  2. removeFlag(String[] options, String flag)
  3. removeFlagsFromArgs(String[] args)
  4. removeFrom(double[] source, int idx)
  5. removeFromArray(String remove, String array[])
  6. removeId(byte[] in, Integer id)
  7. removeIndex(String[] args, int index)
  8. removeIndex(T[] array, int index)
  9. removeLast(byte[] target, int end)