java将字符串定义为null终止吗? [英] Does java define string as null terminated?
问题描述
正如我的标题所示,这是一个理论问题。我想知道如果java将字符串定义为null终止。
As my title suggests, it's a theoretical question. I'd like to know that if java defines string as null terminated.
推荐答案
我会想知道如果java将字符串定义为null终止。
I'd like to know that if java defines string as null terminated.
否。 String定义为 char
值的固定长度序列。可以在String中使用所有可能的 char
值(从0到65535)。没有distinguished值表示字符串结束。
No. A String is defined to be a fixed length sequence of char
values. All possible char
values (from 0 to 65535) may be used in a String. There is no "distinguished" value that means that the string ends.
那么它们如何跟踪字符串结尾?使用长度?
So how they track string ending? Using length?
是的。一个 String
对象有一个私有的长度
字段(在我检查的所有实现中......)。
Yes. A String
object has a private length
field (in all implementations I've examined ...).
如果您想了解有关如何实现Java字符串的更多信息,可以在线获取各种版本的源代码。 Google为java.lang.String source。
If you want to understand more about how Java strings are implemented, the source code for various versions is available online. Google for "java.lang.String source".
这篇关于java将字符串定义为null终止吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!