java & ģʽ
³éÏ󻯺ͼ̳йØÏµÊ¹¸ÅÄîºÍ¶¨Òå¿ÉÒÔ¸´Óã»¶à̬ÐÔʹʵÏÖºÍÓ¦ÓÿÉÒÔ¸´Óã»
¿ª±ÕÔÔò£¨Open-Closed Principle OCP£©Ò»¸öÈí¼þʵÌåÓ¦µ±¶ÔÀ©Õ¹¿ª·Å£¬¶ÔÐ޸ķâ±Õ¡£
¶Ô¿É±äÐԵķâ×°ÔÔò£¨Principle of Encapsulation of Variation£© (1)Ò»Öֱ仯ÐÔ²»ºÍÁíÒ»ÖÖ»ìºÏÔÚÒ»Æð £¨2£©Ò»ÖֿɱäÐÔ²»Ó¦É¢ÂäÔÚ´úÂëµÄºÜ¶àµØ·½¡£
ÀïÊÏ´ú»»ÔÔò£¨Liskov Substitution Principle£©£ºÈκλùÀà³öÏֵĵط½£¬×ÓÀàÒ»¶¨¿ÉÒÔ³öÏÖ¡£
ÒÀÀµµ¹×ªÔÔò£¨Dependence Inversion£©£ºÒªÒÀÀµÓÚ³éÏ󣬲»ÒªÒÀÀµÓÚʵÏÖ¡£
×éºÏ/¾ÛºÏ¸´ÓÃÔÔò£¨ Composite/Aggregate Reuse Principle£©£º¾¡¿ÉÄÜʹÓÃ×éºÏ/¾ÛºÏ£¬¶ø²»ÊǼ̳йØÏµ¡£
µÏÃ×ÌØ·¨Ôò£ºÒ»¸öÈí¼þʵÌåÓ¦¾¡¿ÉÄÜÉÙµØºÍÆäËûÈí¼þʵÌå·¢Éú¹ØÏµ¡£
½Ó¿Ú¸ôÀëÔÔò£¨Interface Segregation Principle£©£ºÏò¿Í»§¶ËÌṩ¾¡¿ÉÄÜСµÄ¶ÀÁ¢µÄ½Ó¿Ú£¬¶ø²»ÊÇ´óµÄ×ܽӿڡ£
CoadÔÔò£¬Ê²Ã´Ê±ºòʹÓü̳и´Óã¿
£¨1£©×ÓÀàÊdz¬ÀàµÄÒ»¸öÌØÊâÖÖÀ࣬²»Êdz¬ÀàµÄÒ»¸ö½ÇÉ«£¬Çø·ÖIs-a£¬Has-a
£¨2£©×ÓÀàÀ©Õ¹³¬ÀàÖ°Ô𣬶ø²»ÊÇ»»µô¡£
£¨3£©ÓÀÔ¶²»»á³öÏÖÐèÒª½«×ÓÀà»»³ÉÁíÒ»¸öÀàµÄ×ÓÀàµÄÇé¿ö¡£
£¨4£©Ö»Ó÷ÖÀàѧÉÏÓÐÒâÒåʱ£¬²ÅʹÓü̳У¬²»Òª´Ó¹¤¾ßÀà¼Ì³Ð¡£
¼¸¸ö¹¤³§Ä£Ê½½â¾ö¶ÔÏó´´½¨¹ý³ÌÖеÄÒÀÀµµ¹×ªÔÔò¡£
Ïà¹ØÎĵµ£º
Ïß³Ì Thread setDaemon ·½·¨
2009Äê07ÔÂ24ÈÕ ÐÇÆÚÎå 14:37
Thread setDaemon ·½·¨
import java.io.IOException;
/*
* ÊØ»¤Ïß³ÌÔÚûÓÐÓû§Ï߳̿ɷþÎñʱ×Ô¶¯À뿪
* ÔÚJavaÖбȽÏÌØÊâµÄÏß³ÌÊDZ»³ÆÎªÊØ»¤£¨Daemon£©Ï̵߳ĵͼ¶±ðÏ̡߳£
* Õâ¸ö ......
Ï̵߳Ĵ´½¨ºÍÆô¶¯
javaÓïÑÔÒѾÄÚÖÃÁ˶àÏß³ÌÖ§³Ö£¬ËùÓÐʵÏÖRunnable½Ó¿ÚµÄÀà¶¼¿É±»Æô¶¯Ò»¸öÐÂỊ̈߳¬ÐÂÏ̻߳áÖ´ÐиÃʵÀýµÄrun()·½·¨£¬µ±run()·½·¨Ö´ÐÐÍê±Ïºó£¬Ï߳̾ͽáÊøÁË¡£Ò»µ©Ò»¸öÏß³ÌÖ´ÐÐÍê±Ï£¬Õâ¸öʵÀý¾Í²»ÄÜÔÙÖØÐÂÆô¶¯£¬Ö»ÄÜÖØÐÂÉú³ÉÒ»¸öÐÂʵÀý£¬ÔÙÆô¶¯Ò»¸öÐÂÏ̡߳£
......
ÏÈ¿´Ò»¶Î´úÂë
public class Hello{
public static void main(String[] args){
int i = 5 , j = 2;
System.out.println(i+j);
System.out.println(i-j);
& ......
1.Java Ô´ÎļþÖÐ×î¶àÖ»ÄÜÓÐÒ»¸ö£¨£©À࣬ÆäËûÀàµÄ¸öÊý²»ÏÞ¡£
publicÀà,¶øÇÒÕâ¸öÀàµÄÀàÃûÒªºÍÎļþÃûÒ»ÖÂ.
2.ÃæÏò¶ÔÏó³ÌÐòÉè¼ÆµÄÌØÕ÷£¨·â×°ÐÔ£©£¨¼Ì³Ð£©£¨¶à̬ÐÔ£©
3.½Ó¿ÚÊÇÓÉ£¨³éÏó·½·¨£©ºÍ£¨³£Á¿£©×é³ÉµÄÌØÊâÀà
4.ÓÃstaticÐÞÊεķ½·¨ÊÇ£¨¾²Ì¬·½·¨£¬»òÀà·½·¨£©
5.ÔÚ²úÉúÒì³£µÄ·½·¨ÉùÃ÷ÖÐÉùÃ÷»á²úÉúµÄ ......