This is the usual way for declare a Java array:
int[] arr = new int[100];
But this array is using heap space. Is there a way we can declare
It's not yet supported as a language feature, because that would require value types since passing on-stack data by reference would not be safe.
But as an optimization (escape analysis) the JVM may already do that for local variables containing small, fixed-size arrays iff it can prove that it does not escape the local/callee scope. That said, it's just a runtime optimization and not some spec guarantee, so relying on it is difficult.