Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVAÖÐStringÓëStringBuffer ¡¢StringBuilderµÄÇø±ð

JAVAÖÐStringÓëStringBuffer ¡¢StringBuilderµÄÇø±ð
Ò»¡¢StringºÍStringBufferµÄÇø±ð
ÔÚjavaÖÐÓÐ3¸öÀàÀ´¸ºÔð×Ö·ûµÄ²Ù×÷¡£
1.Character ÊǽøÐе¥¸ö×Ö·û²Ù×÷µÄ£¬
2.String ¶ÔÒ»´®×Ö·û½øÐвÙ×÷¡£²»¿É±äÀà¡£
3.StringBuffer Ò²ÊǶÔÒ»´®×Ö·û½øÐвÙ×÷£¬µ«ÊǿɱäÀà¡£
StringÊôÐÔ:
*ÊǶÔÏó²»ÊÇԭʼÀàÐÍ.
*Ϊ²»¿É±ä¶ÔÏó,Ò»µ©±»´´½¨,¾Í²»ÄÜÐÞ¸ÄËüµÄÖµ.
*¶ÔÓÚÒѾ­´æÔÚµÄString¶ÔÏóµÄÐ޸ͼÊÇÖØÐ´´½¨Ò»¸öеĶÔÏó,È»ºó°ÑеÄÖµ±£´æ½øÈ¥.
*String ÊÇfinalÀà,¼´²»Äܱ»¼Ì³Ð.
StringBufferÊôÐÔ:
*ÊÇÒ»¸ö¿É±ä¶ÔÏó,µ±¶ÔËû½øÐÐÐ޸ĵÄʱºò²»»áÏñStringÄÇÑùÖØÐ½¨Á¢¶ÔÏó
*ËüÖ»ÄÜͨ¹ý¹¹Ô캯ÊýÀ´½¨Á¢,ÈçStringBuffer sb = new StringBuffer();
*²»ÄÜͨ¹ý¸¶Öµ·ûºÅ¶ÔËû½øÐи¶Öµ.sb = "welcome to here!";//error
*¶ÔÏó±»½¨Á¢ÒÔºó,ÔÚÄÚ´æÖоͻá·ÖÅäÄÚ´æ¿Õ¼ä,²¢³õʼ±£´æÒ»¸önull.
*ÏòStringBufferÖи¶ÖµµÄʱºò¿ÉÒÔͨ¹ýËüµÄappend·½·¨:sb.append("hello");
StringºÍStringBufferµÄ±È½Ï£º
×Ö·û´®Á¬½Ó²Ù×÷ÖÐStringBufferµÄЧÂÊÒª±ÈString¸ß:
String str = new String("welcome to ");
str += "here";
µÄ´¦Àí²½Öèʵ¼ÊÉÏÊÇͨ¹ý½¨Á¢Ò»¸öStringBuffer,È»ºóµ÷ÓÃappend(),×îºó
ÔÙ½«StringBuffer toSting();
ÕâÑùµÄ»°StringµÄÁ¬½Ó²Ù×÷¾Í±ÈStringBuffer¶à³öÁËһЩ¸½¼Ó²Ù×÷,µ±È»Ð§ÂÊÉÏÒª´òÕÛ¿Û.
²¢ÇÒÓÉÓÚString ¶ÔÏóÊDz»¿É±ä¶ÔÏó,ÿ´Î²Ù×÷Sting ¶¼»áÖØÐ½¨Á¢ÐµĶÔÏóÀ´±£´æÐµÄÖµ.
ÕâÑùÔ­À´µÄ¶ÔÏó¾ÍûÓÃÁË,¾ÍÒª±»À¬»ø»ØÊÕ.ÕâÒ²ÊÇÒªÓ°ÏìÐÔÄܵÄ.
¿´¿´ÒÔÏ´úÂ룺
½«26¸öÓ¢ÎÄ×Öď֨¸´¼ÓÁË5000´Î£¬
        String tempstr = "abcdefghijklmnopqrstuvwxyz";
        int times = 5000;
        long lstart1 = System.currentTimeMillis();
        String str = "";
        for (int i = 0; i < times; i++) {
            str += tempstr;
        }
        long lend1 = System.currentTimeMillis();
        long time = (lend1 - lstart1);
       


Ïà¹ØÎĵµ£º

Java ¼¼ÊõÊÇʲô£¿

Java ¼¼ÊõÊÇʲô£¿
Java ¼¼Êõ¼ÈÊÇÒ»Öָ߼¶µÄÃæÏò¶ÔÏóµÄ±à³ÌÓïÑÔ£¬Ò²ÊÇÒ»¸öƽ̨¡£Java ¼¼Êõ»ùÓÚ Java ÐéÄâ»ú£¨Java virtual machine£¬JVM£©µÄ¸ÅÄî —— ÕâÊÇÓïÑÔÓëµ×²ãÈí¼þºÍÓ²¼þÖ®¼äµÄÒ»ÖÖת»»Æ÷¡£Java ÓïÑÔµÄËùÓÐʵÏÖ¶¼±ØÐëʵÏÖ JVM£¬´Ó¶øÊ¹ Java ³ÌÐò¿ÉÒÔÔÚÓÐ JVM µÄÈκÎϵͳÉÏÔËÐС£
Java ±à³ÌÓïÑÔ£¨Java p ......

JAVAÓëactionscriptͨÐÅ ±ðÈ˵ľ­Ñé

 ÎÊÌ⣺
·þÎñÆ÷ÊÇÓÃjavaдµÄ£¬¿Í»§¶ËÊÇÓÃactionscript(ʹÓÃamf3)дµÄ£¬µ«ÊÇ·þÎñÆ÷¶ËÖ»·¢ËÍÁËÁ½´ÎÐÅÏ¢£¬
¿Í»§¶ËÈ´½ÓÊÕµ½Èý´ÎÊý¾Ý£¬·þÎñÆ÷¶ËÒ²ÊÇͬÑùµÄÎÊÌ⣬½ÓÊÕµ½¿Í»§¶ËµÄÈý´ÎÊý¾Ý£¬µ«Êǿͻ§¶ËÒ²Ö»·¢ÁË
Á½´ÎÐÅÏ¢¡£
ÓÉÓÚsocket´«ÊäÊý¾ÝʱÊǰ´¹Ì¶¨µÄ´óС´«ËÍ×Ö½ÚÊý¾ÝµÄ£¬µ«ÊÇÔÚflash¿Í»§¶Ë¶ÁÈ¡µÄ
ʱºòÊÇ¿¿Ò» ......

java ÊäÈë/Êä³öÁ÷С¼Ç£¬ÎļþcopyµÄÀý×Ó

java ÊäÈë/Êä³öÁ÷С¼Ç (2)
×Ö·ûÊäÈëÁ÷
BufferedReader
´Ó Reader ÖжÁÈ¡¶à¸ö×Ö·ûµ½Ò»¸ö»º³åÇø£¬È»ºó·µ»ØÕû¸ö»º³åÇøÄÚÈÝ¡£Ê¹Ð¡Á¿¶Áд¸ü¼Ó
ÓÐЧ¡£
CharArrayReader
´ÓÒ»¸ö Char Êý×éÖÐ˳Ðò¶ÁÈë¶à¸ö×Ö·û
FileReader
´ÓÎļþÖÐ˳Ðò¶ÁÈë¶à¸ö×Ö·û£¬ÊÇ InputStreamReader µÄ×ÓÀ࣬ÄÜ´ÓÒ»¸ö×Ô¶¯´´½¨µÄ
FileInputSt ......

µ±Ç°»ùÓÚWWWµÄЭͬʽCAIÈí¼þµÄJavaʵÏÖ

Õª¡¡Òª¡¡±¾ÎĽéÉÜÒ»¸öÓÃJ++ʵÏֵĻùÓÚWeb»·¾³µÄЭͬʽ¼ÆËã»ú¸¨Öú½ÌѧÈí¼þµÄ½á¹¹£¬²¢¸ø³öÁ˾ßÌåʵÏÖÖеÄһЩ¹Ø¼ü¼¼Êõ¡£
¡¡J++£¬Web£¬Ô¶³Ì½Ìѧ£¬SocketͨÐÅ
1¡¡ÒýÑÔ
¡¡¡¡Ëæ×ÅInternetÍøÂç¼¼ÊõµÄ·¢Õ¹£¬Ô¶³Ì¶àýÌå½Ìѧ³ÉΪµ±Ç°µÄ̽¾¿Èȵ㡣»ùÓÚInternetµÄWWWÓ¦ÓÃģʽ×÷ΪһÖÖ·½±ã¡¢Ñ¸ËٵĹ²ÏíÐÅÏ¢ÊֶΣ¬ÉîÊÜÓû§»¶Ó­¡£Óû§Í ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ