Forums Register Login

Null String

+Pie Number of slices to send: Send
As we all know empty string takes 40 bytes in memory.Could anyone tell me please,how much byte null string takes?
+Pie Number of slices to send: Send
Welcome to CodeRanch!

By 'null' string, what we mean is - a reference of type String, which does not refer to any String object.

Since it does not refer to any object, the question about 'how big the object is' is irrelevant.

I hope this helps.
+Pie Number of slices to send: Send
 

Shripad Katkamwar wrote:As we all know empty string takes 40 bytes in memory. . . .

How do you know?

And welcome again
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:

Shripad Katkamwar wrote:As we all know empty string takes 40 bytes in memory. . . .

How do you know?


And actually, I suspect the statement is wrong, because will take up a different amount of space on a 64-bit machine to a 32-bit one.

Also: If declared or supplied as a literal (""), it will be shared, so the number of bytes it takes up really isn't worth obsessing about, because it will only be created once.

HIH

Winston
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:

Shripad Katkamwar wrote:As we all know empty string takes 40 bytes in memory. . . .

How do you know?



Actually I didn't know that. While programming Java for over 10 years I never found it necessary to care about that sort of thing. Like Winston just said, it isn't worth knowing.
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 514 times.
Similar Threads
Need Help in parsing Japanese SHIFT JIS Characters in Java
How do I read and write a binary file?
Must end with null?
DatagramPacket to String
How to pass a long in ...Long ll = Long.valueOf(3L);//gives
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:18:20.