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

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

 StringºÍStringBufferµÄÇø±ð£¬ÍøÉÏ×ÊÁÏ¿ÉÒÔ˵ÊÇÊý²»Ê¤Êý£¬µ«ÊÇ¿´µ½ÕâƪÎÄÕ£¬¸Ð¾õÀïÃæ×öµÄСÀý×ÓºÜÓдú±íÐÔ£¬ËùÒÔתһÏ£¬²¢×Ô¼º×öÁËÒ»µã×ܽᡣ
ÔÚjavaÖÐÓÐ3¸öÀàÀ´¸ºÔð×Ö·ûµÄ²Ù×÷¡£
1.Character ÊǽøÐе¥¸ö×Ö·û²Ù×÷µÄ£¬
2.String ¶ÔÒ»´®×Ö·û½øÐвÙ×÷¡£²»¿É±äÀà¡£
3.StringBuffer Ò²ÊǶÔÒ»´®×Ö·û½øÐвÙ×÷£¬µ«ÊǿɱäÀà¡£
String:
ÊǶÔÏó²»ÊÇԭʼÀàÐÍ.
Ϊ²»¿É±ä¶ÔÏó,Ò»µ©±»´´½¨,¾Í²»ÄÜÐÞ¸ÄËüµÄÖµ.
¶ÔÓÚÒѾ­´æÔÚµÄString¶ÔÏóµÄÐ޸Ķ¼ÊÇÖØд´½¨Ò»¸öеĶÔÏó,È»ºó°ÑеÄÖµ±£´æ½øÈ¥.
String ÊÇfinalÀà,¼´²»Äܱ»¼Ì³Ð.
StringBuffer:
ÊÇÒ»¸ö¿É±ä¶ÔÏó,µ±¶ÔËû½øÐÐÐ޸ĵÄʱºò²»»áÏñStringÄÇÑùÖØн¨Á¢¶ÔÏó
ËüÖ»ÄÜͨ¹ý¹¹Ô캯ÊýÀ´½¨Á¢,
StringBuffer sb = new StringBuffer();
note:²»ÄÜͨ¹ý¸¶Öµ·ûºÅ¶ÔËû½øÐи¶Öµ.
sb = "welcome to here!";//error
¶ÔÏó±»½¨Á¢ÒÔºó,ÔÚÄÚ´æÖоͻá·ÖÅäÄÚ´æ¿Õ¼ä,²¢³õʼ±£´æÒ»¸önull.ÏòStringBuffer
Öи¶ÖµµÄʱºò¿ÉÒÔͨ¹ýËüµÄappend·½·¨.
sb.append("hello");
×Ö·û´®Á¬½Ó²Ù×÷ÖÐ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);
 &nb


Ïà¹ØÎĵµ£º

[ת]Java »ñÈ¡µ±Ç°Â·¾¶&System.getProperty()²ÎÊý´óÈ«

1¡¢ÀûÓÃSystem.getProperty()º¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
System.out.println(System.getProperty("user.dir"));//user.dirÖ¸¶¨Á˵±Ç°µÄ·¾¶
2¡¢Ê¹ÓÃFileÌṩµÄº¯Êý»ñÈ¡µ±Ç°Â·¾¶£º
File directory = new File("");//É趨Ϊµ±Ç°Îļþ¼Ð
try{
    System.out.println(directory.getCanonicalPa ......

Java µ¼³öexcel£¨¶þ£©

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
......

javaÖмÓÃÜËã·¨µÄÓ¦ÓÃÒ»£ºDES

µÚÒ»ÖÖDES¼ÓÃÜËã·¨
import java.security.Key;
 
import java.security.SecureRandom;
 
import javax.crypto.Cipher;
 
import javax.crypto.KeyGenerator;
 
 
/**

*

* ʹÓÃDES¼ÓÃÜÓë½âÃÜ,¿É¶Ôbyte[],StringÀàÐͽøÐмÓÃÜÓë½âÃÜ ÃÜÎÄ¿ÉʹÓà ......

JavaÖеļòµ¥¹¤³§Ä£Ê½

 JavaÖеļòµ¥¹¤³§Ä£Ê½
      ¾ÙÁ½¸öÀý×ÓÒÔ¿ìËÙÃ÷°×JavaÖеļòµ¥¹¤³§Ä£Ê½£º
Å®æ´ÞÒÍÁÔìÈË
»°Ëµ£º“ÌìµØ¿ª±Ù£¬Î´ÓÐÈËÃñ£¬Å®æ´ÞÒÍÁΪÈË¡£”Å®æ´ÐèÒªÓÃÍÁÔì³öÒ»¸ö¸öµÄÈË£¬µ«ÔÚÅ®æ´Ôì³öÈË֮ǰ£¬È˵ĸÅÄîÖ»´æÔÚÓÚŮ洵Ä˼ÏëÀïÃæ¡£
Å®æ´ÔìÈË£¬Õâ¾ÍÊǼòµ¥¹¤³§Ä£Ê½µÄÓ¦Óá£
¡¡¡¡Ê×ÏÈ£ ......

JavaÒì³£µÄ·ÖÀà

תÔØ×Ô£ºhttp://blog.csdn.net/ilibaba/archive/2009/03/07/3965359.aspx 
±»¼Ü¹¹Ê¦ÎʵÄÃæÊÔÌâ
1. Òì³£»úÖÆ
      Òì³£»úÖÆÊÇÖ¸µ±³ÌÐò³öÏÖ´íÎóºó£¬³ÌÐòÈçºÎ´¦Àí¡£¾ßÌåÀ´Ëµ£¬Òì³£»úÖÆÌṩÁ˳ÌÐòÍ˳öµÄ°²È«Í¨µÀ¡£µ±³öÏÖ´íÎóºó£¬³ÌÐòÖ´ÐеÄÁ÷³Ì·¢Éú¸Ä±ä£¬³ÌÐòµÄ¿ØÖÆȨתÒƵ½Òì³£´¦ÀíÆ÷¡£
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ