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

StringremoveAdditionalRanges(String line, ArrayList indices, ArrayList newRanges)
Removes ranges of characters from a line and adds their indices to an ArrayList.
int offset = 0;
for (int i = 0; i < newRanges.size(); i++) {
    line = line.substring(0, newRanges.get(i)[0]) + line.substring(newRanges.get(i)[1] + 1);
    while (indices.get(offset) <= newRanges.get(i)[0] + offset)
        offset++;
    int insideOffset = 0;
    while (offset + insideOffset < indices.size()
            && indices.get(offset + insideOffset) <= newRanges.get(i)[1] + offset + insideOffset)
...
booleanremoveAllFromArrayList(ArrayList collection, Collection toRemove)
remove All From Array List
boolean result = false;
for (int i = collection.size(); --i >= 0;)
    if (toRemove.contains(collection.get(i))) {
        collection.remove(i);
        result = true;
return result;
voidremoveAllListaProd(ArrayList lista)
remove All Lista Prod
lista = new ArrayList();
ArrayListremoveAlreadyParsedFolders(ArrayList listStrings, String pickup, String limit)
remove Already Parsed Folders
int i;
ArrayList<String> newList = listStrings;
if (!pickup.isEmpty()) {
    for (i = 0; i < listStrings.size(); i++)
        if (listStrings.get(i).contains(pickup)) {
            newList = new ArrayList<>(listStrings.subList(i, listStrings.size()));
            break;
if (!limit.isEmpty()) {
    for (i = 0; i < newList.size(); i++)
        if (newList.get(i).contains(limit)) {
            newList = new ArrayList<>(newList.subList(0, i));
            break;
return newList;
booleanremoveByReference(ArrayList list, T object)
Removes the given object from the list using reference equality, not equals()
if (list == null)
    return false;
int size = list.size();
for (int i = 0; i < size; i++) {
    if (list.get(i) == object) {
        list.remove(i);
        return true;
return false;
ArrayListremoveDuplicates(ArrayList al)
remove Duplicates
Set<String> hs = new HashSet<>();
hs.addAll(al);
al.clear();
al.addAll(hs);
return al;
ArrayListremoveDuplicates(ArrayList a)
remove Duplicates
ArrayList<T> result = new ArrayList<T>();
for (T t : a)
    if (!result.contains(t))
        result.add(t);
return result;
voidremoveDuplicateWithOrder(List arrayList)
remove Duplicate With Order
Set set = new HashSet();
List newList = new ArrayList();
for (Iterator iter = arrayList.iterator(); iter.hasNext();) {
    Object element = iter.next();
    if (set.add(element)) {
        newList.add(element);
arrayList.clear();
arrayList.addAll(newList);
voidremoveElementsFromIndexToEnd(ArrayList list, int index)
remove Elements From Index To End
for (int i = list.size() - 1; i >= index; i--)
    list.remove(i);
StringremoveExtraPunctuation(String line, int startChar, ArrayList indices)
Removes extra punctuation from the passed text that are found in quotations or parentheses.
StringBuffer buffer = new StringBuffer(line);
boolean inParentheses = false;
for (int i = 0; i < buffer.length(); i++) {
    char c = buffer.charAt(i);
    if (c == ')')
        inParentheses = false;
    if (inParentheses || c == '[' || c == ']' || c == '/')
        indices.add(startChar + i);
...