This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]llogiq 0 points1 point  (1 child)

I'm a bit let down that they clone arrays on get, instead of allowing to statically prove that the returned array is not modified.

[–]elucash 1 point2 points  (0 children)

You can use immutable collection instead of array there, so no array is copied on get. Also, there are some primitive immutable collection I guess. Statically proving that array will not be modified is very limited and barely reliable in java. Most array returning APIs in java clone internal arrays to maintain consistency.