Is a Java array of primitives stored in stack or heap?
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 not all primitive variables are local… For example, consider this: public class Foo … Read more