1.1 Java对连接操作(+)和其他对象转换成string提供了特殊的支持。连接操作通过StringBuilder或者StringBuffer的append()方法。
通过toString()方法实现转换操作。
1.2 在string构造器里面放一个null,会导致空指针异常。
1.3 构造器
1. public String() { this.value = "".value; }
2. public String(String original) { this.value = original.value; this.hash = original.hash; }
3. public String(char value[]) { this.value = Arrays.copyOf(value, value.length); } Arrays.copyOf()方法内部调用的是System.arraycopy
4. public String(char value[], int offset, int count)
5. public String(int[] codePoints, int offset, int count)
6. public String(byte ascii[], int hibyte, int offset, int count)
7. public String(byte ascii[], int hibyte)
8. public String(byte bytes[], int offset, int length, String charsetName) throws UnsupportedEncodingException
9. public String(byte bytes[], int offset, int length, Charset charset)
10. public String(byte bytes[], String charsetName) throws UnsupportedEncodingException
11. public String(byte bytes[], Charset charset)
12. public String(byte bytes[], int offset, int length)
13. public String(byte bytes[])
14. public String(StringBuffer buffer)
15. public String(StringBuilder builder)
16. ***String(char[] value, boolean share) 这个很重要,速度很快,但共享char数组。具体看实现。
1.4 内部方法
1. public int length()
2. public boolean isEmpty() { return value.length == 0; }
3. public char charAt(int index)