Java?е?String???????????
???????????? ???????[ 2015/10/12 13:49:22 ] ???????????????????
??????????????????
????????????? ??Java?У? String???????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????
????????Java?????? ????String????????????????????????????
????String s = "ABCabc";
????System.out.println("s = " + s);
????s = "123456";
????System.out.println("s = " + s);
?????????????
????s = ABCabc
????s = 123456
??????????????String????s???????s????“ABCabc”?? ???????s????“123456”?? ????????????????s????????????????????String?????????????? ??????????????????? s??????String?????????????????????????????????????????????????????????????????????????????????4????????????????????????????????????????????????????
??????????s???????????????????????????????s=“123456”; ????????й???????????????μ????“123456”?? ??????s??????????????????????????“ABCabc”????????д????????и????????????????
????Java??C++????????????? ??Java?в?????????????????????е?????????????????????????????ò????????????????????????????????????????????????????????????????C++?д?????????????????????????????????????????????????????Java?е????ú?C++?е??????????????????????????????????????е???????????Java?У??????????????????????Java?е????ò?????C++?е???????????м??????
???????String????????????
????????String?????????????????String???ж?????Щ????????? ??JDK1.6?У?String???????????????????
????public final class String
????implements java.io.Serializable?? Comparable<String>?? CharSequence
????{
????/** 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;
????/** Cache the hash code for the string */
????private int hash; // Default to 0
??????JDK1.7?У?String???????Щ??????????????substring??????????????????????????????JDK1.7??String????????????????????????
????public final class String
????implements java.io.Serializable?? Comparable<String>?? CharSequence {
????/** The value is used for character storage. */
????private final char value[];
????/** Cache the hash code for the string */
????private int hash; // Default to 0
?????????????????????? ??Java??String?????????????????????JDK6?У? value??String????????飬offset??String?????value?????е????λ???count??String?????????????????JDK7?У???????value?????????value?е????????????????String?????????????????????????? ????????????hash????????????String????????????棬???????????????????????????Java?У???????????????ο???????????java?????????????? ????value?????????????????????????????????????????String s = “ABCabc”; ?????????????????沼??????????????
????value??offset??count??????????????private????????????setValue?? setOffset??setCount????????????????Щ?????????String???????????String?????????????????????? ??????String???????????????????????????value??offset??count??????????????final??? ??????String????????????????????????? ???????????????????String??????????????
?????????String?У??????????Щ?????????????????????????????Щ????????substring?? replace?? replaceAll?? toLowerCase??????????′???
????String a = "ABCabc";
????System.out.println("a = " + a);
????a = a.replace('A'?? 'a');
????System.out.println("a = " + a);
?????????????
????a = ABCabc
????a = aBCabc
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11