Effective Java ѧϰ±Ê¼Ç£¨13£©
Ó°ÏìÄ£¿éÉè¼ÆºÃÓ뻵µÄÒ»¸öÖØÒªÒòËؾÍÊÇÕâ¸öÄ£¿éÊÇ·ñÒþ²ØËüµÄÄÚ²¿Êý¾ÝºÍÆäËûһЩʵÏÖϸ½Ú¡£
ÐÅÏ¢Òþ²ØµÄºÃ´¦£º·½±ã¶ÀÁ¢¿ª·¢£¬²âÊÔ£¬ÓÅ»¯£¬Ê¹Óã¬Àí½âºÍÐ޸ġ£Äܹ»Ìá¸ßϵͳ¿ª·¢ËÙ£¨ÒòΪ¸÷Ä£¿é¿ÉÒÔ²¢Ðпª·¢£©£¬Ò²ÄÜÒ×ÓÚά»¤ºÍµ÷ÊÔ£¬Ò²ÄܼõÉÙϵͳ¹¹½¨µÄ·çÏÕ¡£
ÒªÉè¼ÆÁ¼ºÃµÄÄ£¿é£¬¹æÔòºÜ¼òµ¥£¬¾ÍÒ»¾ä»°£ºÊ¹Ã¿¸öÀà»ò½Ó¿Ú¾¡Á¿²»¿É·ÃÎÊ¡£
1.¶ÔÓÚtop-levelµÄÀàºÍ½Ó¿Ú£¨ÓëÎļþÃûÏàͬµÄÀà»ò½Ó¿Ú£©£¬Ö»ÓÐÁ½ÖÖ·ÃÎÊȨÏÞ£º°ü¿É·ÃÎÊ£¬¹«¹²·ÃÎÊ¡£Èç¹ûÕâ¸öÀà¿ÉÒÔÉèΪ°ü¿É·ÃÎÊ£¬ÄÇËü¾ÍÓ¦¸ÃÊÇ°ü¿É·ÃÎÊ£¬ÕâÑùÔÚ½«À´¾Í¿ÉÒÔÐ޸ģ¬Ìæ»»»òɾ³ýÕâЩÀà¶ø²»Ó°ÏìϵͳµÄÏòÉϼæÈÝÐÔ¡£
2. Èç¹ûÒ»¸ö°ü¿É·ÃÎʵÄÀà»ò½Ó¿ÚÖ»ÊDZ»Ò»¸öÀàʹÓã¬ÄÇô¿ÉÒÔ¿¼ÂÇ°ÑÕâ¸öÀà×÷ΪnestedÀà¡£
ÓÐʱΪÁ˲âÊÔ·½Ã棬ÓпÉÄÜ»áÌá¸ßÀà»ò½Ó¿ÚµÄ¿É·ÃÎÊ£¬ÕâÖÖ·½·¨¿ÉÐУ¬µ«Òª×¢Òâ×î¸ßÖ»ÄÜÌáµ½°ü¿É·ÃÎÊÐÔ£¬¶ø²»ÄÜÒòΪ²âÊԾͰÑÏà¹ØÀ౩¶µ½APIÖС£
×Ö¶ÎÓÀÔ¶²»ÄÜΪ¹«¹²µÄ£¬Èç¹ûÒ»¸ö×Ö¶ÎÊÇnon-final,»òÊÇÆäÖ¸ÏòµÄ¶ÔÏóÊǿɸıäµÄ£¬½«ÆäÉè¼ÆΪ¹«¹²·ÃÎÊ£¬¾ÍʧȥÁ˶ÔÆäÖµ½øÐÐÏÞÖƵÄÄÜÁ¦¡£Í¬Ñù£¬Ò²²»ÄÜÔÚÆäÖµ±»Ð޸ĵÄʱºò×öһЩ²Ù×÷¡£Òò´Ë£¬ÕâЩҲ²»ÊÇḬ̈߳²È«µÄ¡£
ÒÔÉÏÔÔòͬÑù¶Ô¾²Ì¬º¯ÊýÊÊÓ㬵«¶Ô³£Á¿×Ö¶ÎÀýÍâ¡£
ҪעÒâÒ»µã£¬Èç¹ûÒ»¸ö¹«¹²µÄfinal×Ö¶ÎÖ¸ÏòµÄÊǿɸıäµÄ¶ÔÏó£¬ÄÇô¾Í»áÓÐDZÔڵݲȫ©¶´¡£
ÈçÏ£º
public static final Thing[] VALUES= {...};
ÓÐÁ½ÖÖ½â¾ö·½Ê½£º
Ò»ÖÖÊÇʹÓÃunmodifiableList,
private static final Thing[] PRIVATE_VALUES = { ... };
public static final List<Thing> VALUES =
Collections.unmodifiableList(Arrays.asList(PRIVATE_VALUES));
ÁíÒ»ÖÐÊÇÓÃclone
private static final Thing[] PRIVATE_VALUES = { ... };
public static final Thing[] values() {
return PRIVATE_VALUES.clone();
}
±¾ÎÄÀ´×ÔCSDN²©¿Í£¬×ªÔØÇë±êÃ÷³ö´¦£ºhttp://blog.csdn.net/mutsinghua/archive/2010/02/05/5290877.aspx
Ïà¹ØÎĵµ£º
annotationʹÓÃ
2010Äê2ÔÂ11ÈÕ ÁɹúÅÖÅÖ
½ñÌì¿´annotation¹æ·¶£¬ÌؼǼÈçÏ£¬ÒÔ±ãÒÔºó²Î¿¼£¬Ò²¹©³õѧµÄÅóÓÑÃÇÒ»¸ö¿ÉÔËÐа¸Àý£¬Óв»Í×Ö®´¦£¬ÇëÖ¸ÕýÐ޸ģ»ÁíÍ⣬ÌرðÉùÃ÷£¬Èç¹ûתÔØ»òÕßÒýÓÃÇë×¢Ã÷³ö´¦¡£
½éÉÜ
AnnotationÊÇjava5ÐÂÌí¼ÓµÄÌØÐÔ£¬ annotationÊÇÒ»ÖÖÔªÊý¾ ......
ΪÁ˽øÐзÇ×èÈûµÄsocketͨÐÅ£¬java nioÌṩChannel¸ÅÄîµÄʵÏÖ¡£Channel¸ÅÄîÒÔÇø±ðÓÚ´«Í³µÄ»ùÓÚÁ÷¸ÅÄîµÄIO¡£ÊÂʵÉÏChannel¸ÅÄîµÄIO¼È°üÀ¨·Ç×èÈûʽµÄIOÒ²°üÀ¨×èÈûʽIO¡£ÒªChannelÍê³É·Ç×èÈûʽIOÐèҪʵÏÖSelectableChannel½Ó¿Ú£¬ÓëSelector¹ØÁªÊ¹Óá£SocketChannel¾ÍÊÇÕâÑùÒ»¸öSelectableChannel¡£
ÓÉÓÚ£¬selector»úÖƱ¾ÉíÉ ......
1.factoryÒòΪ¹¤³§Ä£Ê½¾ÍÏ൱ÓÚ´´½¨ÊµÀý¶ÔÏóµÄnew£¬ÎÒÃǾ³£Òª¸ù¾ÝÀàClassÉú³ÉʵÀý¶ÔÏó£¬
ÈçA a=new A() ¹¤³§Ä£Ê½Ò²ÊÇÓÃÀ´´´½¨ÊµÀý¶ÔÏóµÄ£¬ËùÒÔÒÔºónewʱ¾ÍÒª¶à¸öÐÄÑÛ£¬ÊÇ·ñ¿ÉÒÔ¿¼ÂÇʵÓù¤³§Ä£Ê½£¬
ËäÈ»ÕâÑù×ö£¬¿ÉÄܶà×öһЩ¹¤×÷£¬µ«»á¸øÄãϵͳ´øÀ´¸ü´óµÄ¿ÉÀ©Õ¹ÐԺ;¡Á¿ÉÙµÄÐÞ¸ÄÁ¿¡£
2.PrototypeģʽÔÊÐíÒ»¸ö¶ÔÏóÔÙ´´½¨Á ......
5.
JSP
±ê×¼¶¯×÷¡¢
JSP
Ö¸ÁîÓÃÓÚÒ³ÃæÓëÈÝÆ÷¼äµÄͨÐÅ£¬¶ø
JSP
±ê×¼¶¯×÷ÓÃÓÚÒ³ÃæÓëÒ³Ãæ»òÕßÒ³ÃæÓë×é¼þ¼äµÄͨÐÅ¡£È磺
<jsp:include
page=”localURL” flush=”true”>
6.
JSP
Òþʽ¶ÔÏó
ÔÚ
......