I am just wondering what does the highlighted part of the code do here?
public E next() {
checkForComodification();
int i = cursor;
if (i >= size)
throw new NoSuchElementException();
Object[] elementData = ArrayList.this.elementData;
if (i >= elementData.length)
throw new ConcurrentModificationException();
cursor = i + 1;
return (E) elementData[lastRet = i]; // what exactly does lastRet = i do??
}
does lastRet = i assigns i to lastRet? if so, if i = 3, then we have elementData[lastRet = 3]? but what does that do? I understand if I have elementData[0] then I am retrieving elementData at the 0 position, and if I have elementData[2] then I am retrieving elementData at the 3rd position. But what is elementData[lastRet = i]? is lastRet = i actually checking if lastRet equals to i? like lastRet == i? but if so, why not write lastRet ==i instead? so it shouldn't be checking equality. So what does lastRet = i do? so it assigns i to lastRet? But then I don't understand what the code: elementData[lastRet = i] do exactly?
lastRetand then evaluating it.**to the code is confusing because it's no longer valid. It would be more clear if you removed the**and just left the comment in the code.