<story><title>Inside the JVM: Arrays and how they differ from other objects</title><url>https://blogs.oracle.com/javamagazine/post/java-array-objects</url></story><parent_chain><item><author>alex3305</author><text>In my experience, just a little bit of insider knowledge goes a long ways to making better code. Arrays are fun things, especially when you do a deep dive into the System.arraycopy() function. But the same goes for all Collections in Java. For instance, most of them have a default size (mostly 10), and growing them is a costly operation. So knowing beforehand how large your collection can or may be, can benefit code. I could use this effectively when working with large document XML parsing.&lt;p&gt;I recommend everyone that uses a managed language (Java, C# or others) to at least get a basic understanding of these fundamentals. And also know which collection type to use when.</text></item></parent_chain><comment><author>marginalia_nu</author><text>&amp;gt; For instance, most of them have a default size (mostly 10), and growing them is a costly operation. So knowing beforehand how large your collection can or may be, can benefit code.&lt;p&gt;It&amp;#x27;s really a tricky balance.  Over-allocating collections &amp;quot;just in case&amp;quot; can quite often be very expensive as well, since large array allocations tend to be fairly slow (since e.g. they typically won&amp;#x27;t fit in the TLAB).</text></comment>
<story><title>Inside the JVM: Arrays and how they differ from other objects</title><url>https://blogs.oracle.com/javamagazine/post/java-array-objects</url></story><parent_chain><item><author>alex3305</author><text>In my experience, just a little bit of insider knowledge goes a long ways to making better code. Arrays are fun things, especially when you do a deep dive into the System.arraycopy() function. But the same goes for all Collections in Java. For instance, most of them have a default size (mostly 10), and growing them is a costly operation. So knowing beforehand how large your collection can or may be, can benefit code. I could use this effectively when working with large document XML parsing.&lt;p&gt;I recommend everyone that uses a managed language (Java, C# or others) to at least get a basic understanding of these fundamentals. And also know which collection type to use when.</text></item></parent_chain><comment><author>pjmlp</author><text>I cringe every single time I see a for loop for what System.arraycopy () has been providing since early days.&lt;p&gt;For better or worse, it shows me that the author isn&amp;#x27;t that into Java.</text></comment>