I know that a C string abc would internally be abc\0 in C, is it the same case with Java?
I know that a C string abc would internally be abc\0 in C, is
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Nope, C strings are an array of chars and thus there is no length associated with them. The side affect of this decision is that to determine a string’s length, one must iterate through it to find the
\0, which isn’t as efficient of carrying the length around.Java strings have a char array for their chars and carry an offset length and a string length. This means determining a string’s length is rather efficient.
Source.