java基础,帮看一下,有不明的地方
下面是String类的部分属性和方法;
public final class String{
/** The value is used for character storage. */
private final char value[];
/** The offset is the first index of the storage that is used. */
private final int offset;
/** The count is the number of characters in the String. */
private final int count;
<input type="checkbox" name="public String(String original) {
int size = original.count;
char[] originalValue = original.value;
char[] v;
if (originalValue.length > size) {
// The array representing the String is bigger than the new
// String itself. Perhaps this constructor is being called
// in order to trim the baggage, so make a copy of the array.
int off = original.offset;
v = Arrays.copyOfRange(originalValue, off, off+size);
} else {
// The array representing the String is the same
// size as the String, so no point in making a copy.
v = originalValue;
}
this.offset = 0;
this.count = size;
this.value = v;
}" value="">
}
然后String s1=new String("hello");这个应该调用的是public String(String original) 方法吧?
有几个部分看不懂:
1.public String(String original) ;这个构造方法放在标签里干什么?
2.count\value等属性都是私有的,为什么original.count、original.value在直接调用他?