The key here is “same array”. If you’re adding the same array (polygon.add(pos);), changing its content will reflect everywhere within polygon.
Containers don’t store whole objects, but just their references (memory address).
The key here is “same array”. If you’re adding the same array (polygon.add(pos);), changing its content will reflect everywhere within polygon.
Containers don’t store whole objects, but just their references (memory address).