r/java • u/loicmathieu • Jan 22 '26
Java 26: what’s new?
https://www.loicmathieu.fr/wordpress/informatique/java-26-whats-new/What's new in Java 26 for us, developers
(Bot in English and French)
163
Upvotes
View all comments
Show parent comment
2
u/cogman10 Jan 22 '26
It's certainly fast, using SIMD instructions to do the copy when possible. But faster than doing a quick SIMD copy is not doing the copy at all.
The
toArraymethod requires iterating over all elements of the underlying collection in order to fill up the output array. For example, if the incoming collection is aLinkedList, then the long portion of theaddAllwill be the initial iteration over the linked list elements.The optimization in Java 26 is still valid, It'll obviously be faster since it directly copies the underlying element data using the SIMD instructions. I'm just thinking in terms of non-ArrayList collections being sent in.