
本文共 4482 字,大约阅读时间需要 14 分钟。
���������������������String ���������������������������������������������������������������������������������������������������������������������������������������������������������������String������������������������������������������������������������������
1. String���������
���Java������String���������������������char���������������������������������������������char���������������final������������������������������������String������������������������������String������������������������������������������������������������������������
���������������
String������������������������������������
- value[]���������������������������������������int������
- hash���������String���������������������������0���
2. String������������
String ���������������������������������value������������������������������������������������������
- src������������������������������������������������������String���char������������������������StringBuilder��� StringBuffer������
- offset���������src���������������������
- count���������������������value���������������������
- charset���������������������
���������������������������������������������������������������������������������������������������
3. ���������������������
3.1 ������������������
String���������������������������������������������������
public int getChars(int srcBegin, int srcEnd, char dst[], int dstBegin) { if (srcBegin < 0) { // ������������������������ throw new StringIndexOutOfBoundsException(srcBegin); } if (srcEnd > value.length) { // ������������������������������ throw new StringIndexOutOfBoundsException(srcEnd); } if (srcBegin > srcEnd) { // ������������������ throw new StringIndexOutOfBoundsException(srcEnd - srcBegin); } System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);}
3.2 ������������
-
equals(Object anObject)���������������String���������������������������������������������������
-
regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)���������������������������������������������������������������������������
-
compareTo(String anotherString)������������������Unicode���������������������������������
-
hashCode()���������String���������������
NOTE���compareTo���compareToIgnoreCase������������������������������������������������������������������������������������������������������������������
3.3 ���������������������
-
startsWith(String prefix)������������������������������������������������
-
endsWith(String suffix)������������������������������������������������������������������������������startsWith���������������
���������
public boolean endsWith(String suffix) { return startsWith(suffix, value.length - suffix.value.length);}
4. ������������
4.1 ������������
String���������������������������������indexOf���lastIndexOf���
public int indexOf(int ch, int fromIndex) { // ������������������������}public int lastIndexOf(int ch, int fromIndex) { // ������������������������}
���������������������������������������������������������������������������������������
4.2 ������������������
String������������������������������������������
public int indexOf(String str, int fromIndex) { // ������������������������}
���������������������������������������������
5. ���������������
5.1 ������������������
String������������������������������������
substring(int beginIndex)������������������������������������������������������������������
substring(int beginIndex, int endIndex)������������������������������������������������������������������
5.2 ���������������
-
concat(String str)���������������������������������������������������������
-
String.join(CharSequence delimiter, CharSequence... elements)������������������������������������������������������������������
5.3 ������������
- matches(String regex)���������������������������������������������������������������
6. ���������������
������������������������������toLowerCase���toUpperCase������
6.1 ������������
-
toLowerCase()���������������������������������������
-
toUpperCase()���������������������������������������
6.2 ������������
- trim()���������������������������������������������������
7. ������������
-
toCharArray()���������������������������������������
-
intern()������������������������������������������������������
���������������String������������������������������������Java������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
