My take...does not require the size precondition check but you may want to still catch that if it represents an error of broader scope than this method.

Given this test code...

    // Test code
    List<String> myList = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        myList.add(String.valueOf(i));
    }
    

the 'zeilen' loop can be implemented as ...

    // "before" diagnostics
    System.out.println(zeilen);

    // The 'zeilen' loop
    for (int i = 0, limit = zeilen.size(); i < limit; i++) {
        if ((i+1) % 4 > 0) zeilen.remove(i/4);
    }

    // "after" diagnostics
    System.out.println(zeilen);

and produces

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
[3, 7, 11, 15, 19]

Works with any length list leaving every '4th' element in list.

A few more test cases :

Given                   Results in
[]                      []
[0,1]                   []
[0,1,2,3]               [3]
[0,1,2,3,4]             [3]
[0,1,2,3,4,5,6,7]       [3,7]
[0,1,2,3,4,5,6,7,8]     [3,7]
Answer from user17856705 on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ list-removeint-index-method-in-java-with-examples
List remove(int index) method in Java with Examples - GeeksforGeeks
November 29, 2024 - The remove(int index) method of List interface in Java is used to remove an element from the specified index from a List container and returns the element after removing it.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ java-list-remove-methods-arraylist-remove
How To Use remove() Methods for Java List and ArrayList | DigitalOcean
Learn how to use the remove() method in Javaโ€™s List and ArrayList interfaces with examples for removing by index or object.
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2013 โ€บ 12 โ€บ java-arraylist-remove-method-example
Java ArrayList remove(int index) Method example
September 11, 2022 - It removes an element and returns the same. It throws IndexOutOfBoundsException if the specified index is less than zero or greater than the size of the list (index size of ArrayList). ... package beginnersbook.com; import java.util.ArrayList; public class RemoveExample { public static void ...
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ java โ€บ util โ€บ arraylist_remove.htm
Java ArrayList remove() Method
The Java ArrayList remove(int index) method removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ removing-element-from-the-specified-index-in-java-arraylist
Removing Element from the Specified Index in Java ArrayList - GeeksforGeeks
March 31, 2023 - ... // Java program to show the exception // of remove() method import java.util.ArrayList; public class ArrayListDemo { public static void main(String[] args) { // create an empty array list with an initial capacity ArrayList<Integer> arrlist ...
๐ŸŒ
W3Resource
w3resource.com โ€บ java-tutorial โ€บ arraylist โ€บ arraylist_remove.php
Java ArrayList.remove(int index) Method
August 19, 2022 - Java ArrayList.remove(int index) Method with example: The remove() method is used to remove an element at a specified index from ArrayList. Shifts any subsequent elements to the left (subtracts one from their indices).
Find elsewhere
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java list โ€บ removing an element from an arraylist
Removing an Element From an ArrayList | Baeldung
April 4, 2025 - Using remove passing an index as parameter, we can remove the element at the specified position in the List and shift any subsequent elements to the left, subtracting one from their indices.
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ java โ€บ delete-element-of-arraylist-at-specific-index
How to Delete Element at Specific Index in ArrayList in Java?
December 21, 2020 - To delete Nth element of an ArrayList in Java, we can use ArrayList.remove() method. ArrayList.remove() accepts index of the element to be removed and returns the removed element.
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ ref_arraylist_remove.asp
Java ArrayList remove() Method
The remove() method removes an item from the list, either by position or by value. If a position is specified then this method returns the removed item.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ list-removeint-index-method-in-java-with-examples
List remove(int index) method in Java with Examples - GeeksforGeeks
November 29, 2024 - The remove(int index) method of List interface in Java is used to remove an element from the specified index from a List container and returns the element after removing it.
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 750418 โ€บ java โ€บ Remove-element-ArrayList-List-loop
Remove the element of ArrayList and List in for-loop indexes? (Java in General forum at Coderanch)
March 22, 2022 - No it won't. The ArrayList is still in the same order, minus the removed entries. JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-17 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility ... Tan Quang wrote:Using get(index) with List is a bad thing, but it brings better performance with ArrayList.
๐ŸŒ
Blogger
javahungry.blogspot.com โ€บ 2017 โ€บ 10 โ€บ remove-element-at-specified-index-in-arraylist-remove-method-example.html
remove(int index) method example Java ArrayList | Java Hungry
After that, we are removing three elements at index 0, 2, and 3 respectively by using the remove(index) method. import java.util.*; public class RemoveMethodExample { public static void main(String args[]) { // Creating an object of ArrayList of String Type ArrayList<String> list = new ArrayList<>(); list.add("AA"); list.add("BB"); list.add("CC"); list.add("DD"); list.add("AA"); list.add("ZZ"); System.out.println("Given ArrayList before remove method: "); for(String str : list) { System.out.println(str); } // Using remove(element) method, removing 1st element, size() reduces by 1 list.remove(0
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ java โ€บ how-to-remove-elements-from-arraylist-in-specific-index-range-in-java
How to Remove Elements from ArrayList in Specific Index Range in Java?
December 21, 2020 - To remove elements from ArrayList present in the given Index Range, use ArrayList.removeRange() method. You can call removeRange() method on the ArrayList, with from-index and to-index passed as arguments respectively to the method.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java list โ€บ remove all occurrences of a specific value from a list
Remove All Occurrences of a Specific Value from a List | Baeldung
June 27, 2025 - Calling List.remove() shifts all elements after the removed one to smaller indices. In this scenario, it means that we delete all elements, except the first. When only the first remains, the index 1 will be illegal.
๐ŸŒ
Java67
java67.com โ€บ 2015 โ€บ 06 โ€บ how-to-remove-elements-from-arraylist.html
How to Delete Objects from ArrayList in Java? ArrayList.remove() method Example | Java67
There are actually two methods to remove an existing element from ArrayList, first by using the remove(int index) method, which removes elements with a given index, remember the index starts with zero in ArrayList.