I was trying to add Integers from 2 sets into single Set via for loop and also using addAll() method provided by Collections. For test purpose, I have populated 2 Sets with
Concerning your question about how it is handled internally, just check the available source code, e.g. Ctrl-click in eclipse and find the implementation, which in your case is in AbstractCollection
:
public boolean addAll(Collection extends E> c) {
boolean modified = false;
for (E e : c)
if (add(e))
modified = true;
return modified;
}
(from JDK 1.7)