Java Utililty Methods ArrayList Remove

List of utility methods to do ArrayList Remove

Description

The list of methods to do ArrayList Remove are organized into topic(s).

Method

voidremoveIndex(ArrayList arr, ArrayList idNames)
remove all the relation index for the input array
for (Object item : arr) {
    if (item instanceof ArrayList) {
        removeIndex((ArrayList) item, idNames);
    } else if (item instanceof HashMap) {
        removeIndex((HashMap) item, idNames);
ListremoveLastValues(final ArrayList v, final int remove)
The Method removeLastValues(ArrayList, int) remove the last Values.
if (remove < v.size()) {
    final List<T> l = v.subList(remove, v.size());
    return l;
throw new IllegalArgumentException("You cannot remove "
        + "more element than in the ArrayList exists. \nSize from ArrayList:" + v.size() + "\n"
        + "Elements to be removed:" + remove + "\n The same ArrayList will be returned.");
voidremoveNulls(ArrayList list)
remove Nulls
int pos = 0;
for (int i = 0; i < list.size(); i++) {
    E current = list.get(i);
    if (current != null) {
        if (i != pos) {
            list.set(pos, current);
        pos++;
...
ArrayListremoveRepeatedElems(ArrayList list)
Removes any repeated elements from the input ArrayList; returns a new ArrayList containing all unique elements from the input list.
ArrayList newList = new ArrayList();
iLoop: for (int i = 0; i < list.size(); i++) {
    String str = (String) (list.get(i));
    for (int j = 0; j < newList.size(); j++) {
        if (str.equals((String) (newList.get(j)))) {
            continue iLoop;
    newList.add(str);
return newList;