+ 1
What is the difference between size of a String and length of a String in java?
They both sounds same, but what is the difference?
1 Odpowiedź
+ 4
in evry aspect....
generally :
suppose a string is "asdgh"
it have a specific space...for allocation..
if each char comsumps k memory
its 5*k in total
but length is...number of chars..= 5
so...total memory consumption= length * char space
same as in array
a array of 5 element has length 5
space taken= byte of each elemnt * 5
(assuming all are same element type)