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

»ùÓÚJava 2ƽ̨µÄÒýÓÃÀàʹÓÃÖ¸ÄÏ

Java 2 ƽ̨ÒýÈëÁË java.lang.ref °ü£¬ÆäÖаüÀ¨µÄÀà¿ÉÒÔÈÃÄúÒýÓöÔÏ󣬶ø²»½«ËüÃÇÁôÔÚÄÚ´æÖС£ÕâЩÀ໹ÌṩÁËÓëÀ¬»øÊÕ¼¯Æ÷£¨garbage collector£©Ö®¼äÓÐÏ޵Ľ»»¥¡£Peter Haggar ÔÚ±¾ÎÄÖзÖÎöÁË SoftReference ¡¢ WeakReference ºÍ PhantomReference ÀàµÄ¹¦ÄܺÍÐÐΪ£¬²¢¾ÍÕâЩÀàµÄʹÓøø³öÁËһЩ±à³Ì·ç¸ñÉϵĽ¨Òé¡£
µ±ÔÚ Java 2 ƽ̨ÖÐÊ×´ÎÒýÈë java.lang.ref °ü£¨ÆäÖаüº¬ SoftReference ¡¢ WeakReference ºÍ PhantomReference Àࣩʱ£¬ËüµÄʵÓÃÐÔÏÔÈ»±»¹ý·Ö¿ä´óÁË¡£Ëü°üº¬µÄÀà¿ÉÄÜÊÇÓÐÓõģ¬µ«ÕâЩÀà¾ßÓеÄijЩ¾ÖÏÞÐÔ»áʹËüÃÇÏԵò»ÊǺÜÓÐÎüÒýÁ¦£¬¶øÇÒÆäÓ¦ÓóÌÐòÒ²½«Ìرð¾ÖÏÞÓÚ½â¾öÒ»ÀàÌض¨µÄÎÊÌâ¡£
À¬»øÊÕ¼¯¸ÅÊö
ÒýÓÃÀàµÄÖ÷Òª¹¦ÄܾÍÊÇÄܹ»ÒýÓÃÈÔ¿ÉÒÔ±»À¬»øÊÕ¼¯Æ÷»ØÊյĶÔÏó¡£ÔÚÒýÈëÒýÓÃÀà֮ǰ£¬ÎÒÃÇÖ»ÄÜʹÓÃÇ¿ÒýÓã¨strong reference£©¡£¾ÙÀýÀ´Ëµ£¬ÏÂÃæÒ»ÐдúÂëÏÔʾµÄ¾ÍÊÇÇ¿ÒýÓà obj £º
Object obj = new Object();
obj Õâ¸öÒýÓý«ÒýÓöÑÖд洢µÄÒ»¸ö¶ÔÏó¡£Ö»Òª obj ÒýÓû¹´æÔÚ£¬À¬»øÊÕ¼¯Æ÷¾ÍÓÀÔ¶²»»áÊÍ·ÅÓÃÀ´ÈÝÄɸöÔÏóµÄ´æ´¢¿Õ¼ä¡£
µ± obj ³¬³ö·¶Î§»ò±»ÏÔʽµØÖ¸¶¨Îª null ʱ£¬À¬»øÊÕ¼¯Æ÷¾ÍÈÏΪûÓжÔÕâ¸ö¶ÔÏóµÄÆäËüÒýÓã¬Ò²¾Í¿ÉÒÔÊÕ¼¯ËüÁË¡£È»¶øÄú»¹ÐèҪעÒâÒ»¸öÖØÒªµÄϸ½Ú£º½öƾ¶ÔÏó¿ÉÒÔ±»ÊÕ¼¯²¢²»Òâζ×ÅÀ¬»øÊÕ¼¯Æ÷µÄÒ»´ÎÖ¸¶¨ÔËÐоÍÄܹ»»ØÊÕËü¡£ÓÉÓÚ¸÷ÖÖÀ¬»øÊÕ¼¯Ëã·¨ÓÐËù²»Í¬£¬Ä³Ð©Ëã·¨»á¸üƵ·±µØ·ÖÎöÉú´æÆڽ϶̵ĶÔÏ󣬶ø²»ÊǽÏÀÏ¡¢Éú´æÆڽϳ¤µÄ¶ÔÏó¡£Òò´Ë£¬Ò»¸ö¿É¹©ÊÕ¼¯µÄ¶ÔÏó¿ÉÄÜÓÀÔ¶Ò²²»»á±»»ØÊÕ¡£Èç¹û³ÌÐòÔÚÀ¬»øÊÕ¼¯Æ÷ÊͷŶÔÏó֮ǰ½áÊø£¬ÕâÖÖÇé¿ö¾Í¿ÉÄÜ»á³öÏÖ¡£Òò´Ë£¬¸ÅÀ¨µØ˵£¬ÄúÓÀÔ¶ÎÞ·¨±£Ö¤¿É¹©ÊÕ¼¯µÄ¶ÔÏó×ÜÊǻᱻÀ¬»øÊÕ¼¯Æ÷ÊÕ¼¯¡£
ÕâЩÐÅÏ¢¶ÔÓÚÄú·ÖÎöÒýÓÃÀàÊǺÜÖØÒªµÄ¡£ÓÉÓÚÀ¬»øÊÕ¼¯ÓÐ×ÅÌض¨µÄÐÔÖÊ£¬ËùÒÔÒýÓÃÀàʵ¼ÊÉÏ¿ÉÄÜûÓÐÄúÔ­À´ÏëÏñµÄÄÇôÓÐÓ㬾¡¹ÜÈç´Ë£¬ËüÃǶÔÓÚÌض¨ÎÊÌâÀ´Ëµ»¹ÊǺÜÓÐÓõÄÀà¡£ÈíÒýÓã¨soft reference£©¡¢ÈõÒýÓã¨weak reference£©ºÍÐéÒýÓã¨phantom reference£©¶ÔÏóÌṩÁËÈýÖÖ²»Í¬µÄ·½Ê½À´ÔÚ²»·Á°­ÊÕ¼¯µÄÇé¿öÏÂÒýÓöѶÔÏó¡£Ã¿ÖÖÒýÓöÔÏó¶¼Óв»Í¬µÄÐÐΪ£¬¶øÇÒËüÃÇÓëÀ¬»øÊÕ¼¯Æ÷Ö®¼äµÄ½»»¥Ò²ÓÐËù²»Í¬¡£´ËÍ⣬Õ⼸¸öеÄÒýÓÃÀ඼±íÏÖ³ö±ÈµäÐ͵ÄÇ¿ÒýÓÓ¸üÈõ”µÄÒýÓÃÐÎʽ¡£¶øÇÒ£¬ÄÚ´æÖеÄÒ»¸ö¶ÔÏó¿ÉÒÔ±»¶à¸öÒýÓ㨿ÉÒÔÊÇÇ¿ÒýÓá¢ÈíÒýÓá¢ÈõÒýÓûòÐéÒýÓã©ÒýÓá£ÔÚ½øÒ»²½ÍùÏÂÌÖÂÛ֮ǰ£¬ÈÃÎÒÃÇÀ´¿´¿´Ò»Ð©ÊõÓ
Ç¿¿É¼°¶ÔÏó£¨strongly reachable£©£º¿ÉÒÔͨ¹ýÇ¿ÒýÓ÷ÃÎʵĶÔÏó¡£
Èí¿É¼°¶ÔÏó£¨softl


Ïà¹ØÎĵµ£º

java ×ÖÌåÉèÖÃ

Ò»¸öJava×ÖÌåÉèÖóÌÐò£¬°üÀ¨´óС£¬ÑÕÉ«£¬¼Ó´Ö£¬Ï»®Ïߣ¬¶ÔÆ룬бÌåµÄÉèÖ㬺ÜÈ«!!! ÊÕ²Ø
Swing¶ÔJTextPaneÖÐ×ÖÌåÑÕÉ«µÄÉèÖÃ
ת×Ô£ºhttp://www.blogjava.net/Swing/archive/2007/12/26/128965.html
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.a ......

Îå¡¢javaµÄÃæÏò¶ÔÏó³ÌÐòÉè¼Æ(ÀàºÍ¶ÔÏó)

Îå¡¢javaµÄÃæÏò¶ÔÏó³ÌÐòÉè¼Æ(ÀàºÍ¶ÔÏó)
/**
 * ÃæÏò¶ÔÏóÖ®Ò»
 * ÀàÓë¶ÔÏó
 */
/**
 * ¶ÔÏóµÄʵÀý»¯¹ý³Ì:
 * 1,javaÖÐËùÓÐÀàÐÍÔÚÄÚ´æµÄ·ÖÅäÇé¿ö
 * a,»ù±¾ÀàÐÍ"±äÁ¿"char,byte,short,int,long,float,double,boolean´æ´¢ÔÚ¶ÑÕ»ÖÐ
 *   ¶ÑÕ»ÊÇͨ¹ý¶ÑÕ»Ö¸Õë°´ÕÕÏȽøÏȳöµÄ¶ÁÈ ......

java×Ü½á µÚÁùÕÂ

µÚÁùÕÂ
javaÀàÉè¼Æ
extendsÀàµÄ¼Ì³Ð
objectÀàÊÇËùÓÐjavaÀàµÄ×î¸ß²ã¸¸Àà
javaÖ»Ö§³Öµ¥¼Ì³Ð ²»ÔÊÐí¶àÖؼ̳Ð
Ò»¸ö×ÓÀàÖ»ÓÐÒ»¸ö¸¸Àà Ò»¸ö¸¸Àà¿ÉÓÃÓжà¸ö×ÓÀà
public default protected public
·½·¨ÖØд
ÔÚ×ÓÀà¿ÉÓøù¾ÝÐèÒª¶Ô¸¸Àà¼Ì³ÐµÄ·½·¨½øÐиÄÔì--·½·¨µÄÖØд
ÖØд·½·¨±ØÐëºÍ±»ÖØд·½·¨¾ßÓÐÏàͬµÄ·½·¨Ãû³Æ ²ÎÊýÁбí ......

java×Ü½á µÚÆßÕÂ

µÚÆßÕÂ
¸ß¼¶ÀàÌØÕ÷
static
ÀàÊôÐÔÓɸÃÀàµÄËùÓÐʵÀý¹²Ïí
public static int total=0;
µ±totalËùÊôÀà±»Êý´ÎʵÀý»¯µÄʱºò totalÖ»ÓÐÒ»¸ö¶ø²»ÊǶà¸ö
Ò²¿É¾²Ì¬³õʼ»¯static
public static int total£»
static{
total=100;
}
static±ê¼ÇµÄ±äÁ¿»òÕß·½·¨ÓÉÕû¸öÀà(ËùÓÐʵÀý)¹²Ïí
µ¥×Óģʽ
class Single{
   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ