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

Java»ù´¡ÎÊÌ⣺java.lang.String

Ô­ÎÄ: http://forum.javaeye.com/viewtopic.php?t=17912§Ö÷µÄÎÊÌâÎʵĺ¬º¬ºýºý:flyjie¸ø³öÁ˷dz£ÏêϸµÄ½âÊÍ£¬²»¹ý¾ÍÊÇûÓнâÊÍStringʵÀý»¯µÄÌØÊâ·½ÃæÒÔ¼°Intern()·½·¨µÄº¬Òå-------------------------------------------------------------------------------------------------------------------------------------------------------------------------java´úÂë: String str ; ÕâÑùÉùÃ÷strËüÖ»Ö§ÊÇÒ»¸ö¶ÔÏóµÄreference£¬²»»á²úÉúʵ¼ÊµÄ¶ÔÏó¡£Èç¹ûûÓгõʼ»¯str£¬±àÒëʱ±ã»á·¢Éú´íÎó¡£ java´úÂë: String str1=new String("test"); String str2 = "test"; str1ÊÇÒ»¸öеĶÔÏó¡£new¹Ø¼ü×ÖµÄÒâ˼¾ÍÊÇ´´½¨Ä³¸öеĶÔÏ󡣶østr2ÊÇÒ»¸ö¶ÔÏóµÄÒýÓᣡ¡ËüÃǵÄÄÚÈÝÏàͬ£¬µ«ÄÚ´æµØÖ·ÊDz»Ò»ÑùµÄ¡£ javaÖжÔÏóµÄÒýÓôæÔÚStack(Õ»)ÖУ¬¶ø¶ÔÏóÓÉHeap(¶Ñ)·ÖÅä¿Õ¼ä¡£ 3¡¢ÒýÓÃ==±äÁ¿? ¡¡²»Ò»¶¨ java´úÂë: ¡¡ public class TestString { public static void main(String[] args) { String s1 = "test"; String s2 = new String("test"); if (s1 == s2) System.out.println("s1 == s2"); else System.out.println("s1 != s2"); if (s1.equals(s2)) System.out.println("s1 equals s2"); else System.out.println("s1 not equals s2"); } } ÎÒÃǽ« s2 Óà new ²Ù×÷·û´´½¨³ÌÐòÊä³ö£ºs1 != s2 s1 equals s2. java´úÂë: s2 = s2.intern(); ÔÚÄã¼ÓÉÏÕâ¾ä»°ºó£¬ÉÏÃæµÄ³ÌÐòÊäÈ룺s1 == s2¡¡s1 equals s2 ¶øString a = "test" ; String b = "test" ; a == b »á·µ»Øtrue; ÕâÀïa="test"ʱ´´½¨Ò»¸öÔÚÕ»ÖеÄreference, b=testʱjvm·¢ÏÖÕ»ÖÐÒÑ´æÔÚÃûΪ"test"µÄ×Ö·û´®£¬Ö±½ÓÒýÓ᣽áÂÛ£ºString ÊǸö¶ÔÏó£¬Òª¶Ô±ÈÁ½¸ö²»Í¬µÄString¶ÔÏóµÄÖµÊÇ·ñÏàͬÃ÷ÏÔµÄÒªÓõ½ equals() Õâ¸ö·½·¨. ¶ø== ±È½ÏµÄÊÇÄÚ´æµØÖ·µÄÖµ¡£ 4¡¢private final String a = "test", Õâ¸öaÊôÓÚ³£Á¿£¬´æ·ÅÔÚ³£Á¿´æ´¢¿Õ¼ä(CS)ÖС£ 5¡¢½¨ÒéÄã¿´¿´<<ÉîÈëdz³öjavaÐéÄâ»ú>>Ò»Êé¡£ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------×ܽá1. ÔÚѧϰJAVAµÄʱºò¾ÍÖªµÀ£½£½±È½ÏµÄÊÇÄÚ´æµØÖ·.¶øequals±È½ÏµÄÊÇÄÚ´æµØÖ·¶ÔÓ¦µÄÖµ£¡£¨¿ÉÊÇ»¹ÊÇÓкܶàµÄ


Ïà¹ØÎĵµ£º

javaÖеõ½µ±Ç°Â·¾¶µÄ·½·¨


¹éÄÉһЩÍøÉÏÈ¡JAVA·¾¶µÄ·½·¨£º
×¢Ã÷£ºÈç¹û´ÓANTÆô¶¯³ÌÐò£¬this.getClass().getResource("")È¡³öÀ´µÄ±È½Ï¹Ö£¬Ö±½ÓÓÃJAVAÃüÁîÐе÷ÊԾͿɳɹ¦¡£
µÃµ½classpathºÍµ±Ç°ÀàµÄ¾ø¶Ô·¾¶µÄһЩ·½·¨
»ñµÃCLASSPATHÖ®Íâ·¾¶µÄ·½·¨£º
URL base = this.getClass£¨£©.getResource£¨""£©£» //ÏÈ»ñµÃ±¾ÀàµÄËùÔÚλÖã¬Èç/home/popeye/ ......

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;
/**
 * ¼ÆËã ......

javaÖÐStirngÀàµÄÉ

³£¿´µ½ºÜ¶àÈËÌÖÂÛjavaÖйØÓÚStringµÄÎÊÌâ,ÎÒÒ²¾ÍÓеãÐËȤÁË,¼øÓÚÍøÉϺܶàÈËдµÄ¶¼²î±ðºÜ´ó,
ͬÑùµÄÎÊÌⶼÊDz»Í¬µÄ˵·¨,ÎÒºÜÃÔºý,»¨ÁËÒ»ÍíÉ϶ÁÁËJava Virtual Machine SpecificationºÍ
The Java Language SpecificationµÄһЩÕ½Ú,×öÁ˺ܶàÊÔÑé,×ܽáÁËһϹØÓÚStringµÄÄÚÈÝ,»¹
ÓкܶàÄÚÈÝÎÒÒ²²»È·¶¨,ÔÚÏÂÃæÒ²¶¼Ìá³öÀ´ÁË,Ï ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ