(一).String类是不可以被继承的,因为被final修饰,public final class String implements java.io.Serializable, Comparable<String>, CharSequence {}
(二).String类的构造方法只列举前四种,如下:
1.public String() {//无参的构造方法,也是最常用的
this.value = new char[0];
}
2.public String(String original) {//参数是String类型的
this.value = original.value;
this.hash = original.hash;
}
3.public String(char value[]) {//参数是char[]数组类型的
this.value = Arrays.copyOf(value, value.length);
}
4.public String(char value[], int offset, int count) {//参数是char[]数组并指定位置的
if (offset < 0) {
throw new StringIndexOutOfBoundsException(offset);
}
if (count < 0) {
throw new StringIndexOutOfBoundsException(count);
}
// Note: offset or count might be near -1>>>1.
if (offset > value.length - count) {
throw new StringIndexOutOfBoundsException(offset + count);
}
this.value = Arrays.copyOfRange(value, offset, offset+count);
}