I get an java.lang.IndexOutOfBoundsException for this code.
private List<Integer> LoeschenX = new ArrayList<Integer>();
private List<Integer> LoeschenY = new ArrayList<Integer>();
for (int i : LoeschenY) LoeschenX.add(LoeschenY.get(i));
When you do
for (int i : LoeschenY)
you are looping over the elements of LoeschenY, not on indexes. You may want to iterate over indexes so you can use get(i):
for (int i = 0; i < LoeschenY.size(); i++)
LoeschenX.add(LoeschenY.get(i));
Remember that get(index) will return the value in an specific index.
Edit: You can also try
for (int i : LoeschenY)
LoeschenX.add(i);
since i takes the values of the elements of LoeschenY, you will add these values to LoeschenX.
iis not the index, it's the int value hold by each Integer object during the iteration. I.e if your list contains 4,-5,12, i will be equals to 4 (iteration 1), -5(iteration 2) and 12(iteration 3).