Java-公共字符串(char []值)

Arp*_*sss 3 java string

我的问题是关于:Public String(char [] value)。有人可以帮我吗:它是否在内部为每个值[i]循环。特别,

Public String(char [] value)的含义是:

for each char[i]
returnedSTRING = returnedSTRING + char[i] 
Run Code Online (Sandbox Code Playgroud)

或不 ?

Chr*_*911 6

Java是开放源代码,如果将源代码附加到Eclipse,则始终可以使用F3来检查功能。在这种情况下,String类具有以下所要查找的构造函数:

/**
 * Allocates a new {@code String} so that it represents the sequence of
 * characters currently contained in the character array argument. The
 * contents of the character array are copied; subsequent modification of
 * the character array does not affect the newly created string.
 *
 * @param  value
 *         The initial value of the string
 */
public String(char value[]) {
    int size = value.length;
    this.offset = 0;
    this.count = size;
    this.value = Arrays.copyOf(value, size);
}
Run Code Online (Sandbox Code Playgroud)

编辑:如果您想知道,Arrays.copyOf调用System.arraycopy