??????Android/Java?????У???????????????????????3??: String??StringBuilder??StringBuffer??
??????????????
????1) ???? final ?? ????????????;
????2) String ???????????? StringBuffer??StringBuilder ?????????;
????3) StringBuffer ?????????? StringBuilder ????????????
????String VS StringBuffer
????String ?????StringBuffer?????????????String?????????? ???????ζ?String ??????и??????????????????μ? String ??????????????μ? String ?????????????????????????ò???? String ????????????????????????????????????????????????????? JVM ?? GC ?????????????????
??????? StringBuffer ???????ζ???? StringBuffer ????????в????????????????μ?????????????á??????????????????? StringBuffer ????????????????????????????
???????Щ???????£? String ??????????????????? Java Compiler ??????? StringBuffer ???????????????Щ??? String ?????????????? StringBuffer ???????????磺
????String s1 = “This is only a” + “ simple” + “ test”;
????StringBuffer Sb = new StringBuilder(“This is only a”).append(“ simple”).append(“ test”);
???????? String s1????????????? StringBuffer?????????Java Compiler??????????????????
????Java Compiler??????????????????????
????String s2 = “This is only a”;
????String s3 = “ simple”;
????String s4 = “ test”;
????String s1 = s2 + s3 + s4;
?????????Java Compiler??????????????????????String??concatenation????+????????????StringBuilder????StringBuffer????append????????????????????????????s2??s3??s4????String???壬????????????????StringBuffer????StringBuilder???????StringBuffer????String???????StringBuffer????StringBuilder?????????????StringBuffer??
????StringBuilder
????StringBuilder??5.0?????????????????? StringBuffer ????? API????????????????????????? StringBuffer ??????????滻????????????????????????????????????????????飩?????????????????????????????????????У????? StringBuffer ????????????????????