So ArrayList in JAVA has 2 remove function 1 return the oldvalue and the other return boolean.
remove(Object) return boolean
remove(index) return oldvalue
now if both the object also integer then how JAVA differentiate
Ex:- in the code arr.remove(j);
Code
ArrayList<Integer> arr = new ArrayList<Integer>();
for (int i = 2; i < 239697453; i++) {
arr.add(i);
}
int a = arr.size();
for (int i = 2; i < a; i++) {
for (int j = 0 j < a; j++) {
if (arr.get(j) % i == 0) {
arr.remove(j);
}
}
}