java ioc³õѧ
Ò»¡¢Ê²Ã´ÊÇIOC
IoC¾ÍÊÇInversion of Control£¬¿ØÖÆ·´×ª¡£ÔÚJava¿ª·¢ÖУ¬IoCÒâζ׎«ÄãÉè¼ÆºÃµÄÀཻ¸øϵͳȥ¿ØÖÆ£¬¶ø²»ÊÇÔÚÄãµÄÀàÄÚ²¿¿ØÖÆ¡£Õâ³ÆΪ¿ØÖÆ·´×ª¡£
ÏÂÃæÎÒÃÇÒÔ¼¸¸öÀý×ÓÀ´ËµÃ÷ʲôÊÇIoC
¼ÙÉèÎÒÃÇÒªÉè¼ÆÒ»¸öGirlºÍÒ»¸öBoyÀ࣬ÆäÖÐGirlÓÐkiss·½·¨£¬¼´GirlÏëÒªKissÒ»¸öBoy¡£ÄÇô£¬ÎÒÃǵÄÎÊÌâÊÇ£¬GirlÈçºÎÄܹ»ÈÏʶÕâ¸öBoy£¿
ÔÚÎÒÃÇÖйú£¬³£¼ûµÄ£Í£ÍÓëGGµÄÈÏʶ·½Ê½ÓÐÒÔϼ¸ÖÖ
£±¡¡Çà÷ÖñÂí£» £²¡¡Ç×ÓѽéÉÜ£» £³¡¡¸¸Ä¸°ü°ì
ÄÇôÄÄÒ»ÖÖ²ÅÊÇ×îºÃÄØ£¿
Çà÷ÖñÂí£ºGirl´ÓС¾ÍÖªµÀ×Ô¼ºµÄBoy¡£
public class Girl {
void kiss(){
Boy boy = new Boy();
}
}
È»¶ø´Ó¿ªÊ¼¾Í´´½¨µÄBoyȱµã¾ÍÊÇÎÞ·¨ÔÚ¸ü»»¡£²¢ÇÒÒª¸ºÔðBoyµÄÕû¸öÉúÃüÖÜÆÚ¡£Èç¹ûÎÒÃǵÄGirlÏëÒª»»Ò»¸öÔõô°ì£¿£¨±ÊÕßÑÏÖز»Ö§³ÖGirl¾³£¸ü»»Boy£©
Ç×ÓѽéÉÜ£ºÓÉÖмäÈ˸ºÔðÌṩBoyÀ´¼ûÃæ
public class Girl {
void kiss(){
Boy boy = BoyFactory.createBoy();
}
}
Ç×ÓѽéÉÜ£¬¹ÌÈ»ÊǺá£Èç¹û²»ÂúÒ⣬¾¡¹ÜÁíÍâ»»Ò»¸öºÃÁË¡£µ«ÊÇ£¬Ç×ÓÑBoyFactory¾³£ÊÇÒÔSingletonµÄÐÎʽ³öÏÖ£¬²»È»¾ÍÊÇ£¬´æÔÚÓÚGlobals£¬ÎÞ´¦²»ÔÚ£¬ÎÞ´¦²»ÄÜ¡£ÊµÔÚÊÇÌ«·±ËöÁËÒ»µã£¬²»¹»Áé»î¡£ÎÒΪʲôһ¶¨ÒªÕâ¸öÇ×ÓѲôºÍ½øÀ´ÄØ£¿ÎªÊ²Ã´Ò»¶¨Òª¸¶¸øËý½éÉÜ·ÑÄØ£¿ÍòÒ»×îºÃµÄÅóÓÑ°®ÉÏÁËÎÒµÄÄÐÅóÓÑÄØ£¿
¸¸Ä¸°ü°ì£ºÒ»Çн»¸ø¸¸Ä¸£¬×Ô¼º²»Ó÷Ѵµ»ÒÖ®Á¦£¬Ö»ÐèÒªµÈ×ÅKiss¾ÍºÃÁË¡£
public class Girl {
void kiss(Boy boy){
// kiss boy
boy.kiss();
}
}
Well£¬ÕâÊǶÔGirl×îºÃµÄ·½·¨£¬Ö»ÒªÏë°ì·¨»ß¸ÁËGirlµÄ¸¸Ä¸£¬²¢°ÑBoy½»¸øËû¡£ÄÇôÎÒÃǾͿÉÒÔÇáËɵĺÍGirlÀ´KissÁË¡£¿´À´¼¸Ç§Ä괫ͳµÄ¸¸Ä¸Ö®Ãü»¹ÕæÊÇÓÐÓÃŶ¡£ÖÁÉÙBoyºÍGirl²»ÓÃ×Ô¼
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
Ò»¡¢·ºÐÍ(Generic)
JDK5ÒÔÇ°£¬¶ÔÏó±£´æµ½¼¯ºÏÖоͻáʧȥÆäÌØÐÔ£¬È¡³öʱͨ³£Òª³ÌÐòÔ±ÊÖ¹¤½øÐÐÀàÐ͵ÄÇ¿ÖÆת»»£¬ÕâÑù²»¿É±ÜÃâ¾Í»áÒý·¢³ÌÐòµÄһЩ°²È«ÐÔÎÊÌâ
Ø·ºÐεÄ×÷Óãº
JDK5ÖеķºÐÎÔÊÐí³ÌÐòÔ±ÔÚ±àд¼¯ºÏ´úÂëʱ£¬¾ÍÏÞÖƼ¯ºÏµÄ´¦ÀíÀ ......
ÎÒÃÇÖªµÀ£¬ÍøÒ³ÓÎÏ·£¨Web game£©¼òµ¥½²ÊÇ»ùÓÚÍøÕ¾¿ª·¢¼¼Êõ£¬ÒÔ±ê×¼httpÐÒéΪ»ù´¡±íÏÖÐÎʽµÄÎÞ¿Í»§¶Ë»ò»ùÓÚä¯ÀÀÆ÷Äں˵Ä΢¿Í»§¶ËÓÎÏ·¡£ÍøÒ³ÓÎÏ·³öÏֵúÜÔ磬×îÔçµÄÍøÒ³ÓÎÏ·Æäʵ¾ÍÊÇһЩÓÃHTMLдµÄ¼òµ¥ÍøÒ³£¬½çÃæ¼òª£¬½»»¥ÊÖ¶Îƶ·¦£¬Íæ¼ÒÓëÓÎÏ·µÄÿ´Î½»»¥¶¼»áÒýÆðä¯ÀÀÆ÷Ë¢ÆÁÒ»´Î£¬Òò´ËÒ»Ö±ÄÑÒÔµÇÉÏ´óÑÅÖ®Ìá£ÔÙÕߣ¬ºÜÖØÒªµÄ ......
java ²Ù×÷cookie
----------------------------------------------------------------------------------------------------------------------------------------------------
дÈëcookie
£¼%
String cookieName="Sender";
Cookie cookie=new Cookie(cookieName, "Test_Content");
cookie.setMaxAge(10);
respo ......