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

javaÖÐStirngÀàµÄÉ

³£¿´µ½ºÜ¶àÈËÌÖÂÛjavaÖйØÓÚStringµÄÎÊÌâ,ÎÒÒ²¾ÍÓеãÐËȤÁË,¼øÓÚÍøÉϺܶàÈËдµÄ¶¼²î±ðºÜ´ó,
ͬÑùµÄÎÊÌⶼÊDz»Í¬µÄ˵·¨,ÎÒºÜÃÔºý,»¨ÁËÒ»ÍíÉ϶ÁÁËJava Virtual Machine SpecificationºÍ
The Java Language SpecificationµÄһЩÕ½Ú,×öÁ˺ܶàÊÔÑé,×ܽáÁËһϹØÓÚStringµÄÄÚÈÝ,»¹
ÓкܶàÄÚÈÝÎÒÒ²²»È·¶¨,ÔÚÏÂÃæÒ²¶¼Ìá³öÀ´ÁË,Ï£Íû¸ßÊÖÄÜÖ¸Õý.
Constant Pool³£Á¿³ØµÄ¸ÅÄî:
ÔÚ½²µ½StringµÄһЩÌØÊâÇé¿öʱ,×Ü»áÌáµ½String Pool»òÕßConstant Pool,µ«ÊÇÎÒÏëºÜ¶àÈ˶¼²»Ì«
Ã÷°×Constant Poolµ½µ×ÊǸöÔõôÑùµÄ¶«Î÷,ÔËÐеÄʱºò´æ´¢ÔÚÄÄÀï,ËùÒÔÔÚÕâÀïÏÈ˵һÏÂConstant PoolµÄÄÚÈÝ.
String PoolÊǶÔÓ¦ÓÚÔÚConstant PoolÖд洢String³£Á¿µÄÇøÓò.Ï°¹ß³ÆΪString Pool,Ò²ÓÐÈ˳ÆΪ
String Constant Pool.ºÃÏñûÓÐÕýʽµÄÃüÃû??
ÔÚjava±àÒëºÃµÄclassÎļþÖÐ,ÓиöÇøÓò³ÆΪConstant Pool,ËûÊÇÒ»¸öÓÉÊý×é×é³ÉµÄ±í,ÀàÐÍ
Ϊcp_info constant_pool[],ÓÃÀ´´æ´¢³ÌÐòÖÐʹÓõĸ÷ÖÖ³£Á¿,°üÀ¨Class/String/IntegerµÈ¸÷
ÖÖ»ù±¾JavaÊý¾ÝÀàÐÍ,ÏêÇé²Î¼ûThe Java Virtual Machine Specification 4.4Õ½Ú.
¶ÔÓÚConstant Pool,±íµÄ»ù±¾Í¨ÓýṹΪ:
cp_info {
        u1 tag;
        u1 info[];
}
tagÊÇÒ»¸öÊý×Ö,ÓÃÀ´±íʾ´æ´¢µÄ³£Á¿µÄÀàÐÍ,ÀýÈç8±íʾStringÀàÐÍ,5±íʾLongÀàÐÍ,info[]¸ù¾Ý
ÀàÐÍÂëtagµÄ²»Í¬»á·¢ÉúÏàÓ¦±ä»¯.
¶ÔÓÚStringÀàÐÍ,±íµÄ½á¹¹Îª:
CONSTANT_String_info {
        u1 tag;
        u2 string_index;
}
tag¹Ì¶¨Îª8,string_indexÊÇ×Ö·û´®ÄÚÈÝÐÅÏ¢,ÀàÐÍΪ:
CONSTANT_Utf8_info {
        u1 tag;
        u2 length;
        u1 bytes[length];
}
tag¹Ì¶¨Îª1,lengthΪ×Ö·û´®µÄ³¤¶È,bytes[length]Ϊ×Ö·û´®µÄÄÚÈÝ.
(ÒÔÏ´úÂëÔÚjdk6ÖбàÒë)
ΪÁËÏêϸÀí½âConstant PoolµÄ½á¹¹,ÎÒÃDzο´Ò»Ð©´úÂë:
    String s1 = "sss111";
    String s2 = "sss222";
    System.out.println(s1 + " " + s2);
ÓÉÓÚ"sss111"ºÍ"sss222"¶¼ÊÇ×Ö·û´®³£Á¿,ÔÚ±àÒëÆÚ¾ÍÒѾ­´´½¨ºÃÁË´æ´¢ÔÚclassÎļþÖÐ.
ÔÚ±àÒëºóµÄclassÎļþÖлá´æÔÚÕâ2¸ö³£Á¿µÄ¶ÔÓ¦±íʾ:
08


Ïà¹ØÎĵµ£º

¿ª²©——¡¾×ª¡¿JavaÖÐDAOµÄʵÏÖ

×î½üѧϰÖÐ×ÜÊǸоõÍ£Ö¹²»Ç°ÁË£¬µ½´ïÒ»¸öÆ¿¾±£¬¾­³£Ð´µ½Ò»¸öµØ·½»á¾õµÃÕâ¸ö¶«Î÷ѧ¹ýµ«Óв»ÊÇÄÇôµÄÇå³þ£¬Ò»ÖÖËƶ®·Ç¶®µÄ¸Ð¾õ£¬ËùÒÔ¾ö¶¨Õҵط½°ÑÿÌìËùѧϰµÄ»òÓÐÓõĶ«Î÷¼Ç¼ÏÂÀ´£¬½ñÌ쿪ʼÕâÀォÊÇÎҵļ¼Êõ¿â£¬ÎÒ»áÓëËùÓа®ºÃJAVAµÄÅóÓÑÒ»Æðѧϰ£¬Ò»Æð½ø²½¡£½ñÌìÊÇ¿ª²©µÚÒ»Ì죬ÕýºÃÔÚ¸´Ï°DAOÉè¼Æģʽ£¬¿´µ½Ò»Æ¬²»´íµÄ½²½â£ ......

JAVA°´ºº×Ö°´Í·×ÖĸÅÅÐò

public static void main(String args[]) {
Comparator cmp = (RuleBasedCollator)java.text.Collator.getInstance(java.util.Locale.CHINA);
String[] array = {"ÕÅÈý", "ÀîËÄ", "ÍõÎå"};
Arrays.sort(array, cmp);
for(String str : array){
System.out.println(str);
}
} ......

javaÖеĶѺÍÕ»

Ò».¶Ñ:ÓÃnew¹Ø¼ü×Ö½¨Á¢,´æ·Å¶ÔÏóµÄÄÚÈÝ,GC¸ºÔð×Ô¶¯»ØÊÕ
ÄãÓÃÊ®¼¸¸öÂ齫ÅÆÊúÖ±µþ³ÉÒ»ÞûÕâ½Ð¶Ñ£¬Äã¿ÉÒÔ´ÓÉÏÃæ¡¢ÏÂÃæ¡¢ÖмäÈÎÒâ³é³öÒ»ÕÅÅÆ£¬Ò²¿ÉÒÔÈÎÒâ²åÈëÒ»ÕÅ¡£ËùÒԶѺÜÁé»î£¬µ«²»°²È«¡£¶ÔÓÚ¶ÔÏó£¬ÎÒÃÇÒª¶¯Ì¬µØ´´½¨¡¢Ïú»Ù£¬²»ÄÜ˵ºó´´½¨µÄ¶ÔÏóûÓÐÏú»Ù£¬ÏÈÇ°´´½¨µÄ¶ÔÏó¾Í²»ÄÜÏú»Ù£¬ÄÇÑùµÄ»°ÎÒÃǵijÌÐò¾Í´ç²½ÄÑÐУ¬ËùÒÔJavaÖ ......

JavaÖеÄÖµ´«µÝÓëÒýÓô«µÝ


Ò».Á½¸ö¸ÅÄî
ʵ¼Ê²ÎÊý(ʵ²Î):·½·¨µ÷ÓÃʱ±»´«ÈëµÄ²ÎÊý
ÐβÎ:·½·¨¶¨ÒåʱÉùÃ÷µÄ²ÎÊý
¶þ.ÈýÖÖ´«µÝ·½Ê½
1.»ù±¾Êý¾ÝÀàÐ͵ÄÖµ´«µÝ:
public static void main(String []args)
 {
  int i=10,j=5;
  tValue(i,j);
  System.out.println("i:"+i+"j:"+j);//´òÓ¡½á¹û:i=10,j=5
 } ......

JavaÀàÇó½âÒ»Ôª¶þ´Î·½³ÌµÄ¸ù

 Ù¡Ç¿ http://blog.csdn.net/microtong
 OakCMSÄÚÈݹÜÀíϵͳ http://www.oakcms.cn http://www.oakcms.net
Ò»Ôª¶þ´Î·½³Ìax2+bx+c=0£¬ÊäÈëa,b,cÈý¸öϵÊý£¬Çó½â·½³Ì£¬½á¹ûÓÐÈýÖÖÇé¿ö£ºÁ½¸öʵÊý¸ù¡¢Ò»¸öʵÊý¸ù¡¢Á½¸ö¸´Êý¸ù¡£
/**
 * Equation.java
 */
package cn.edu.uibe.oop;
/**
 * ¼ÆËã ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ