?????????μ???£???????????????????java??string???ЩС??????????????????????????????á???????????????????а??????????????string?????????????????????????????????

????String?????????????????????????????????д???????????????????????????C???????java?У?jdk??????????????????????????????????????String ??StringBuffer ?? StringBuilder .?????????????????????????????????????????????

??????????????String??

????JDK??????? “Strings are constant?? their values cannot be changed after they are created”????String??????????????????????????????????????????????????????????????????????????????????????????????д??

???????????????????????????????????String????

???????????????????????java?????????й?????????????string???????????????????????????????????????????????????е?????????У????????????????????????????????С??????????????????int??????????????????????

???????????????????????????????鳣?????????????????“string”??????????????????е????????????str1??????λ?á?

???????????????????????????new??????????java????????java??new??????????У?????????????????????????????????????????new??????????????????????????????????????????????

????д???С????

    String str1 = "string"; 
            String str4 = "string"; 
            String str2 = new String??"string"??; 
            String str3 = new String??"string"??; 
             
            /*????????????????????????????*/
            System.out.println??str1 == str4??; 
            System.out.println??str2 == str3??; 
            System.out.println??str3 == str1??; 
             
            str3 = str3.intern????; //??????????????
            System.out.println??str3 == str1??;

????????????н????

????true //???????????????????????????????????????е?????????

????false //?????????new??????????μ????

????false // ????? ???==??????????????????????

????true //???????intern?????????????????????????????????е????????????????????????str3?????????string?????????????????У???????????д??????string??????????????str3?????????str1??????

????????????????string???????????????????????????????????????????string?????????????str1 + "some"??????????????ζ?string??????????????????μ????

????????????????????????????????????Ч????????????????????????????????????????????μ???????????????????????????????

    long start = System.currentTimeMillis????; 
             
            for??int i = 0; i < 50000; i++?? 
            { 
                str1+= " "; 
            } 
             
            long end = System.currentTimeMillis????; 
            System.out.println??"the run time is "+??end -start??+" ms"??;

???????????????н????the run time is 3538 ms ???????????????????????????0?????????????????????????????????JDK??ν?????????