Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 ÀàµÄ·¾¶

public class Path {
 //get class absolute address
 public String getPath() {
  String classPath = getClass().getName();
  if (classPath.indexOf(".") != -1) {
   classPath = classPath.substring(classPath.lastIndexOf(".") + 1,
     ......

JavaʼþÄ£ÐÍѧϰ£¨2£©

       µ±³ÌÐòµÄij¸öÄ£¿é±»µ÷ÓõÄʱ¿Ì²»È·¶¨£¬¾ÍÀàËÆÓڵȴýij¸öʼþµÄ·¢Éú¡£Õâʱ£¬¿ÉÒÔ¶¨Òå×Ô¼ºµÄʼþ½øÐÐÏàÓ¦µÄ´¦Àí¡£±ÈÈ磬µÈ´ýÓû§µÄÒ»´ÎÊäÈëµÈ¡£JavaµÄʼþÄ£ÐÍÒÀÀµÓÚίÍУ¬Í¨¹ý»Øµ÷·½·¨½øÐÐÏàÓ¦µÄʼþ´¦Àí¡£ÔÚʼþÔ´ÖУ¬»áÓÐfireXXXEvent()¾ÍÊǼ¤»îÏàÓ¦µÄʼþ£¬ÆäÖлá±éÀúʼþÔ´µÄ¼àÌýÆ ......

ÔÚJavaÖÐÀûÓÃcglibʵÏÖ´úÀí


    ÔÚÉÏһƪÎÄÕ¡¶ÔÚJavaÖÐÀûÓö¯Ì¬´úÀíʵÏÖÊý¾Ý¿âÁ¬½ÓÓëÊÂÎñµÄ×Ô¶¯¹ÜÀí¡·½²ÊöÁËÈçºÎʹÓÃJava¶¯Ì¬´úÀí£¬µ«ÒªÇó±»´úÀí¶ÔÏóҪʵÏÖÒ»¸ö½Ó¿Ú£¬Èç¹û²»ÏëʵÏÖ½Ó¿ÚÔõô°ìÄØ£¿Ê¹ÓÿªÔ´µÄcglib¿ÉÒÔʵÏÖ¶ÔÒ»¸öÀà¶ÔÏóµÄ´úÀí£¬¶ø²»ÒªÇóʵÏÖ½Ó¿Ú¡£
    cglib£¨Code Generation Library£©Äܹ»ÔÚ³ÌÐòÔË ......

javaÓÅÊÆ¼°¿çƽ̨ԭÀí

Ò»¡£javaµÄÓÅÊÆ
1.ÃæÏò¶ÔÏó
2.¿çƽ̨
java×÷ΪһÖÖÍøÂçÓïÑÔ£¬ÆäÔ´´úÂë±»±àÒë³É.class×Ö½ÚÂ룬ÓÉjavaÐéÄâ»úÖ´ÐУ¬
3.¼òµ¥
Ò»£¬java·ç¸ñÀàËÆc++£¬c++³ÌÐòÔ±ÄÜºÜ¿ìµØÕÆÎÕjava
¶þ£¬javaÞðÆúÁËÖ¸Õ룬½á¹¹£¬Ã¶¾ÙµÈÒ×Òý·¢ÄÚ´æÎÊÌâµÄ²Ù×÷
Èý£¬javaÌṩÁ˷ḻµÄapi£¬Äܹ»°ïÖúÎÒÃÇ¿ìËÙ¿ª·¢
4.½¡×³
Ò»¡£Ç¿ÀàÐ͵ģ¬ÀàÐͼì²éºÜÑ ......

JavaºÍC++λÔËËã¶Ô±È

ΪÁËʵÏÖÁ½¸öÊý×Ö½øÐн»»»£¬ÎÒÃÇͨ³£¿ÉÒÔÀûÓÃλÔËËãÀ´ÊµÏÖ
C++³ÌÐò     swap(int a  ,int b){a^=b^=a^=b;}
JAVA³ÌÐò    swap(int a, int b){  a^=b;b^=a;a^=b; }»òÕß{ b^=(a^=b) ; a^=b;}
Èç¹ûJAVAÓÃC++µÄʵÏÖ·½Ê½Ôò»áµÃµ½ bµÃµ½ÁËaµÄÖµ£¬µ«ÊÇaÏÖÔÚµÄֵȴ² ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ