Java - 公共字符串(char []值) [英] Java - Public String(char[] value)

查看:183
本文介绍了Java - 公共字符串(char []值)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是:公共字符串(char []值)。任何人都可以帮助我:它是否内部循环每个值[i]或不。具体来说,

My question is about: Public String(char[] value). Can anybody help me: does it internally loops for every value[i] or not. Specifically,

公共字符串(char []值)表示:

does Public String(char[] value) means:

for each char[i]
returnedSTRING = returnedSTRING + char[i] 

或不是吗?

推荐答案

Java是开源的,如果你将源附加到Eclipse,你总是可以使用F3去检查函数。在这种情况下,String类具有以下构造函数,这是您正在寻找的:

Java is open source and if you attach the source to Eclipse you can always use F3 to go check the functions. In this case the String class has the following constructor which is what you are looking for:

/**
 * 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);
}

编辑:如果您想知道, Arrays.copyOf 调用< a href =http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#arraycopy%28java.lang.Object,%20int,%20java.lang.Object,%20int ,%20int%29rel =nofollow> System.arraycopy 。

If you are wondering, Arrays.copyOf calls System.arraycopy.

这篇关于Java - 公共字符串(char []值)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆