Originally posted by amal shah:
Hello,
How to calculate the size of a string. I have a requirement wherein to calculate the size of an object. The closest that i would come up with is:
say for eg: a string is "amal"
now considering that a character is 2 bytes....so the size of above string is 8 bytes. Is my assumption right?
help appreciated
cheers
amal shah
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Originally posted by amal shah:
...I have a requirement wherein to calculate the size of an object...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
When I see questions like this, I always wonder if there's a professor out there who has thrown together a Java course using old material from other languages.
An important question is WHY do you feel you need to know? What are you trying to accomplish?
If it's nothing more than a theoretical exercise for a class or for fun, that's one thing. But in the real world, this is seldom, if ever, an issue.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tell me how it all turns out. Here is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|