android - Do Java Ellipsis Require Heap Allocation? -


is there kind soul out there somewhere knows whether or not java's ellipsis implementation involves heap allocation behind scene. seems reasonable me calling method necessaries on stack , avoid array/heap allocation altogether, when comes java i've been proven wrong more times can count. if knows sure, grateful answer.

yes, creating array. it's possible in some cases jvm can clever stuff notice array can never "escape", , can created on stack - that's nothing varargs syntax, just syntactic sugar.

in general, should treat other array creation. this:

public void foo(int... args) // code foo(1, 2, 3); 

is equivalent to:

public void foo(int[] args) // code foo(new int[] { 1, 2, 3 }); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -