remove Array Item - Java Collection Framework

Java examples for Collection Framework:Array Auto Increment

Description

remove Array Item

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public final static Integer[] removeArrayItem(Integer[] array,
            Integer item) {/*w w w. j a v a2s  .  co  m*/
        List<Integer> list = new ArrayList<Integer>();
        for (Integer arrayItem : array) {
            if (!arrayItem.equals(item))
                list.add(arrayItem);
        }

        Integer[] ret = new Integer[list.size()];
        list.toArray(ret);
        return ret;
    }
}

Related Tutorials