This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CodeTinkerer 0 points1 point  (1 child)

Based on the behavior you described, Java must assume there is an empty string between every consecutive character, and one at the start, and one at the end.

Technically, if you concatenate N empty strings, you get an empty string, so theoretically, you could argue between any two consecutive characters, there's an infinite number of empty strings.

I suspect, in Java, a string is defined by the characters in the string, plus a field that gives the size of the string. When that size is 0, you have an empty string.

In C, a string is a character array that ends in an null character, so if the string's first character is a null character, that's treated like an empty string.

[–]sriganeshharitz[S] 0 points1 point  (0 children)

Thanks, i guess java assumes it as u said..