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

JAVA×Ô¶¯×°ÏäÓë²ðÏä

×Ô¶¯×°ÏäÓë²ðÏäµÄ¹¦ÄÜÊÂʵÉÏÊDZàÒëÆ÷À´°ïÄúµÄ棬±àÒëÆ÷ÔÚ±àÒëʱÆÚÒÀÄúËù±àдµÄÓï·¨£¬¾ö¶¨ÊÇ·ñ½øÐÐ×°Ïä»ò²ðÏ䶯×÷¡£ÀýÈ磺
Integer i = 100.Ï൱ÓÚ±àÒëÆ÷×Ô¶¯ÎªÄú×÷ÒÔϵÄÓï·¨±àÒ룺
Integer i = new Integer(100).ËùÒÔ×Ô¶¯×°ÏäÓë²ðÏäµÄ¹¦ÄÜÊÇËùνµÄ“±àÒëÆ÷ÃÛÌÇ”(Compiler Sugar)£¬ËäȻʹÓÃÕâ¸ö¹¦Äܷܺ½±ã£¬µ«ÔÚ³ÌÐòÔËÐн׶ÎÄúµÃÁ˽âJavaµÄÓïÒå¡£ÀýÈçÏÂÃæµÄ³ÌÐòÊÇ¿ÉÒÔͨ¹ý±àÒëµÄ£º
Integer i = null.int j = i.ÕâÑùµÄÓï·¨ÔÚ±àÒëʱÆÚÊǺϷ¨µÄ£¬µ«ÊÇÔÚÔËÐÐʱÆÚ»áÓдíÎó£¬ÒòΪÕâÖÖд·¨Ï൱ÓÚ£º
Integer i = null.int j = i.intValue().null±íʾiûÓвο¼ÖÁÈκεĶÔÏóʵÌ壬Ëü¿ÉÒԺϷ¨µØÖ¸¶¨¸ø¶ÔÏó²Î¿¼Ãû³Æ¡£ÓÉÓÚʵ¼ÊÉÏi²¢Ã»Óвο¼ÖÁÈκεĶÔÏó£¬ËùÒÔÒ²¾Í²»¿ÉÄܲÙ×÷intValue()·½·¨£¬ÕâÑùÉÏÃæµÄд·¨ÔÚÔËÐÐʱ»á³öÏÖNullPointerException´íÎó¡£
×Ô¶¯×°Ïä¡¢²ðÏäµÄ¹¦ÄÜÌṩÁË·½±ãÐÔ£¬µ«Òþ²ØÁËһЩϸ½Ú£¬ËùÒÔ±ØÐëСÐÄ¡£ÔÙÀ´¿´·¶Àý4.6£¬ÄúÈÏΪ½á¹ûÊÇʲôÄØ£¿
ü. ·¶Àý4.6 AutoBoxDemo2.java
public class AutoBoxDemo2 {
public static void main(String[] args) {
Integer i1 = 100.
Integer i2 = 100.
if (i1 == i2)
System.out.println("i1 == i2").
else
System.out.println("i1 != i2").
}
}
´Ó×Ô¶¯×°ÏäÓë²ðÏäµÄ»úÖÆÀ´¿´£¬¿ÉÄÜ»á¾õµÃ½á¹ûÊÇÏÔʾi1 == i2£¬ÄúÊǶԵġ£ÄÇô·¶Àý4.7µÄÕâ¸ö³ÌÐò£¬Äú¾õµÃ½á¹ûÊÇʲô£¿
ü. ·¶Àý4.7 AutoBoxDemo3.java
public class AutoBoxDemo3 {
public static void main(String[] args) {
Integer i1 = 200.
Integer i2 = 200.
if (i1 == i2)
System.out.println("i1 == i2").
else
System.out.println("i1 != i2").
}
}
½á¹ûÊÇÏÔʾi1 != i2£¬ÕâÓÐЩÁîÈ˾ªÑÈ£¬Á½¸ö·¶ÀýÓï·¨ÍêÈ«Ò»Ñù£¬Ö»²»¹ý¸Ä¸öÊýÖµ¶øÒÑ£¬½á¹ûÈ´Ïà·´¡£
ÆäʵÕâÓë==ÔËËã·ûµÄ±È½ÏÓйأ¬ÔÚµÚ3ÕÂÖнéÉܹý==ÊÇÓÃÀ´±È½ÏÁ½¸ö»ù±¾Êý¾ÝÀàÐ͵ıäÁ¿ÖµÊÇ·ñÏàµÈ£¬ÊÂʵÉÏ==Ò²ÓÃÓÚÅжÏÁ½¸ö¶ÔÏóÒýÓÃÃû³ÆÊÇ·ñ²Î¿¼ÖÁͬһ¸ö¶ÔÏó¡£
ÔÚ×Ô¶¯×°Ïäʱ¶ÔÓÚÖµ´Ó–128µ½127Ö®¼äµÄÖµ£¬ËüÃDZ»×°ÏäΪInteger¶ÔÏóºó£¬»á´æÔÚÄÚ´æÖб»ÖØÓã¬ËùÒÔ·¶Àý4.6ÖÐʹÓÃ==½øÐбȽÏʱ£¬i1 Óë i2ʵ¼ÊÉϲο¼ÖÁͬһ¸ö¶ÔÏó¡£Èç¹û³¬¹ýÁË´Ó–128µ½127Ö®¼äµÄÖµ£¬±»×°ÏäºóµÄInteger¶ÔÏó²¢²»»á±»ÖØÓ㬼´Ï൱ÓÚÿ´Î×°Ïäʱ¶¼Ð½¨Ò»¸öInteger¶ÔÏó£¬ËùÒÔ·¶Àý4.7ʹÓÃ==½øÐбȽÏʱ£¬i1Óëi2²Î¿¼µÄÊDz»Í¬µÄ¶ÔÏó¡£
ËùÒÔ²»Òª¹ý·ÖÒÀÀµ×Ô¶¯×°ÏäÓë²ðÏ䣬Äú»¹ÊDZØÐëÖªµÀ


Ïà¹ØÎĵµ£º

dzÎöJava·ºÐÍ

±íÃæÉÏ¿´ÆðÀ´£¬ÎÞÂÛÓï·¨»¹ÊÇÓ¦ÓõĻ·¾³£¨±ÈÈçÈÝÆ÷Àࣩ£¬·ºÐÍÀàÐÍ£¨»òÕß·ºÐÍ£©¶¼ÀàËÆÓÚ C++ ÖеÄÄ£°å¡£µ«ÊÇÕâÖÖÏàËÆÐÔ½öÏÞÓÚ±íÃ棬Java ÓïÑÔÖеķºÐÍ»ù±¾ÉÏÍêÈ«ÔÚ±àÒëÆ÷ÖÐʵÏÖ£¬ÓɱàÒëÆ÷Ö´ÐÐÀàÐͼì²éºÍÀàÐÍÍƶϣ¬È»ºóÉú³ÉÆÕͨµÄ·Ç·ºÐ͵Ä×Ö½ÚÂë¡£ÕâÖÖʵÏÖ¼¼Êõ³ÆΪ²Á³ý£¨erasure£©£¨±àÒëÆ÷ʹÓ÷ºÐÍÀàÐÍÐÅÏ¢±£Ö¤ÀàÐÍ°²È«£¬È»ºóÔ ......

ÈçºÎÌá¸ß×Ô¼ºµÄJava±à³Ìˮƽ

       1.
ÔúʵµÄ»ù´¡¡£Êý¾Ý½á¹¹¡¢ÀëÉ¢Êýѧ¡¢±àÒëÔ­Àí£¬ÕâЩÊÇËùÓмÆËã»ú¿ÆѧµÄ»ù´¡£¬Èç¹û²»ÕÆÎÕËûÃÇ£¬ºÜÄÑд³ö¸ßˮƽµÄ³ÌÐò¡£¾ÝÎҵĹ۲죬ѧ¼ÆËã»úרҵµÄÈ˱ÈѧÆäËû
רҵµÄÈ˸üÄÜд³ö¸ßÖÊÁ¿µÄÈí¼þ¡£³ÌÐòÈËÈ˶¼»áд£¬µ«µ±Äã·¢ÏÖдµ½Ò»¶¨³Ì¶ÈºÜÄÑÔÙÌá¸ßµÄʱºò£¬¾ÍÓ¦¸ÃÏëÏëÊDz»ÊÇÒª»Ø¹ýÍ·À´ ......

JavaÓëCͨÐÅҪעÒâµÄ¼¸¸öÎÊÌâ

1.´óβ(big_endian)Сβ(little_endian)µÄÎÊÌâ
»ùÓÚWebµÄ²âÊÔÈí¼þÊÇÓÉC++Êý¾Ý²É¼¯·þÎñÆ÷³ÌÐòºÍ¿Í»§¶ËJavaÏÔʾ³ÌÐòÁ½²¿·Ö¹¹³É£¬Ç°ÕßÓÃC++£¬ºóÕßJavaÓïÑÔ£¬´æÔÚÊý¾ÝÒÆÖ²ÎÊÌâ¡£ÒòΪ
ÔÚ¼ÆËã»úϵͳÖУ¬µ±°üº¬Êý×ֵĶþ½øÖÆÎļþ´ÓÒ»¸ö½á¹¹ÒƵ½ÁíÒ»½á¹¹Ê±£¬¾Í³öÏÖ´óβСβÎÊÌâ¡£²»Í¬CPUÔÚ¶à×Ö½ÚÊý£¨ÈçËÄ×Ö½Úint£©´æ´¢Ê±ÓÐÁ½ÖÖ·½·¨ ......

JavaÓëCͨÐÅҪעÒâµÄ¼¸¸öÎÊÌâ

1.´óβ(big_endian)Сβ(little_endian)µÄÎÊÌâ
»ùÓÚWebµÄ²âÊÔÈí¼þÊÇÓÉC++Êý¾Ý²É¼¯·þÎñÆ÷³ÌÐòºÍ¿Í»§¶ËJavaÏÔʾ³ÌÐòÁ½²¿·Ö¹¹³É£¬Ç°ÕßÓÃC++£¬ºóÕßJavaÓïÑÔ£¬´æÔÚÊý¾ÝÒÆÖ²ÎÊÌâ¡£ÒòΪ
ÔÚ¼ÆËã»úϵͳÖУ¬µ±°üº¬Êý×ֵĶþ½øÖÆÎļþ´ÓÒ»¸ö½á¹¹ÒƵ½ÁíÒ»½á¹¹Ê±£¬¾Í³öÏÖ´óβСβÎÊÌâ¡£²»Í¬CPUÔÚ¶à×Ö½ÚÊý£¨ÈçËÄ×Ö½Úint£©´æ´¢Ê±ÓÐÁ½ÖÖ·½·¨ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ