I wonder how many bytes are in the java array

Asked 2 years ago, Updated 2 years ago, 63 views

int [6] = { 11, 22, 33, 44, 55, 66 };

Is the total number of bytes in the above array 24 bytes?

java array

2022-09-22 18:32

1 Answers

There's one thing you need to know before you answer the question.

In Java, an array is an object. It does not create on the stack, such as c/c++.

In other words, the array elements are stored in the heap, and the starting address of the elements is stored in the stack.

So you're using 24 bytes for the hip.I don't think so. The type, length, and gc of the array will also be stored. So it's hard to know how much space you're going to use in the heap.


2022-09-22 18:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.