Reputation: 8453
What would be the memory size/space occupied in bits/bytes by array as follows.
final String[] objects_user1={"1","10","100","1000","10000"};
Upvotes: 0
Views: 644
Reputation: 626
You can get an approximate answer by querying available heap space before & after the memory allocation. Run it a number of times & compute the average, & it will be pretty close to the right answer. But again, the answer is only valid for the specific JVM it's run on.
Upvotes: 0
Reputation: 19225
Impossible to say, since its an implementation detail of the JRE you're using.
Upvotes: 0
Reputation: 19187
ROUGH ESTIMATE: 12 bytes for array header, 4x5 bytes for the pointers (8x5 if you're on a 64 bit jvm), each string has 3 ints (+3x4 bytes), and an array of chars (+12 bytes for header + length of the string x2, because it's char).
Upvotes: 4
Reputation: 42464
Did you try to Google it? Here is the first result of my Google search.
Upvotes: 0