Is a Java array of primitives stored in stack or heap?
问题 I have an array declaration like this: int a[]; Here a is an array of primitive int type. Where is this array stored? Is it stored on heap or stack? This is a primitve type int , all primitive types are not stored on heap. 回答1: As gurukulki said, it's stored on the heap. However, your post suggested a misunderstanding probably due to some well-intentioned person propagating the myth that "primitives always live on the stack". This is untrue. Local variables have their values on the stack, but