ÉîÈëÀí½âjava abstract classºÍinterface[ZT]
abstract classºÍinterfaceÊÇJavaÓïÑÔÖжÔÓÚ³éÏóÀඨÒå½øÐÐÖ§³ÖµÄÁ½ÖÖ»úÖÆ£¬ÕýÊÇÓÉÓÚÕâÁ½ÖÖ»úÖƵĴæÔÚ£¬²Å¸³ÓèÁËJavaÇ¿´ó
µÄÃæÏò¶ÔÏóÄÜÁ¦¡£abstract classºÍinterfaceÖ®¼äÔÚ¶ÔÓÚ³éÏóÀඨÒåµÄÖ§³Ö·½Ãæ¾ßÓкܴóµÄÏàËÆÐÔ£¬ÉõÖÁ¿ÉÒÔÏ໥Ìæ»»£¬Òò´ËºÜ¶à¿ª·¢Õß
ÔÚ½øÐгéÏóÀඨÒåʱ¶ÔÓÚabstract classºÍinterfaceµÄÑ¡ÔñÏԵñȽÏËæÒâ¡£Æäʵ£¬Á½ÕßÖ®¼ä»¹ÊÇÓкܴóµÄÇø±ðµÄ£¬¶ÔÓÚËüÃǵÄÑ¡ÔñÉõÖÁ·´
Ó³³ö¶ÔÓÚÎÊÌâÁìÓò±¾ÖʵÄÀí½â¡¢¶ÔÓÚÉè¼ÆÒâͼµÄÀí½âÊÇ·ñÕýÈ·¡¢ºÏÀí¡£±¾ÎĽ«¶ÔËüÃÇÖ®¼äµÄÇø±ð½øÐÐÒ»·¬ÆÊÎö£¬ÊÔͼ¸ø¿ª·¢ÕßÌṩһ¸öÔÚ¶þÕßÖ®¼ä½øÐÐÑ¡ÔñµÄÒÀ
¾Ý¡£
Àí½â³éÏóÀà
abstract classºÍinterfaceÔÚJavaÓïÑÔÖж¼ÊÇÓÃÀ´½øÐгéÏóÀࣨ±¾ÎÄÖÐ
µÄ³éÏóÀಢ·Ç´Óabstract class·Òë¶øÀ´£¬Ëü±íʾµÄÊÇÒ»¸ö³éÏóÌ壬¶øabstract classΪJavaÓïÑÔÖÐÓÃÓÚ¶¨Òå³éÏóÀàµÄÒ»ÖÖ·½
·¨£¬Çë¶ÁÕß×¢ÒâÇø·Ö£©¶¨ÒåµÄ£¬ÄÇôʲôÊdzéÏóÀ࣬ʹÓóéÏóÀàÄÜΪÎÒÃÇ´øÀ´Ê²Ã´ºÃ´¦ÄØ£¿
ÔÚÃæÏò¶ÔÏóµÄ¸ÅÄîÖУ¬ÎÒÃÇÖªµÀËùÓеĶÔÏó¶¼ÊÇͨ
¹ýÀàÀ´Ãè»æµÄ£¬µ«ÊÇ·´¹ýÀ´È´²»ÊÇÕâÑù¡£²¢²»ÊÇËùÓеÄÀ඼ÊÇÓÃÀ´Ãè»æ¶ÔÏóµÄ£¬Èç¹ûÒ»¸öÀàÖÐûÓаüº¬×ã¹»µÄÐÅÏ¢À´Ãè»æÒ»¸ö¾ßÌåµÄ¶ÔÏó£¬ÕâÑùµÄÀà¾ÍÊdzéÏóÀà¡£³é
ÏóÀàÍùÍùÓÃÀ´±íÕ÷ÎÒÃÇÔÚ¶ÔÎÊÌâÁìÓò½øÐзÖÎö¡¢Éè¼ÆÖеóöµÄ³éÏó¸ÅÄÊǶÔһϵÁп´ÉÏÈ¥²»Í¬£¬µ«ÊDZ¾ÖÊÉÏÏàͬµÄ¾ßÌå¸ÅÄîµÄ³éÏó¡£±ÈÈ磺Èç¹ûÎÒÃǽøÐÐÒ»¸öͼÐÎ
±à¼Èí¼þµÄ¿ª·¢£¬¾Í»á·¢ÏÖÎÊÌâÁìÓò´æÔÚ×ÅÔ²¡¢Èý½ÇÐÎÕâÑùһЩ¾ßÌå¸ÅÄËüÃÇÊDz»Í¬µÄ£¬µ«ÊÇËüÃÇÓÖ¶¼ÊôÓÚÐÎ×´ÕâÑùÒ»¸ö¸ÅÄÐÎ×´Õâ¸ö¸ÅÄîÔÚÎÊÌâÁìÓòÊDz»´æÔÚ
µÄ£¬Ëü¾ÍÊÇÒ»¸ö³éÏó¸ÅÄî¡£ÕýÊÇÒòΪ³éÏóµÄ¸ÅÄîÔÚÎÊÌâÁìÓòûÓжÔÓ¦µÄ¾ßÌå¸ÅÄËùÒÔÓÃÒÔ±íÕ÷³éÏó¸ÅÄîµÄ³éÏóÀàÊDz»Äܹ»ÊµÀý»¯µÄ¡£
ÔÚÃæÏò
¶ÔÏóÁìÓò£¬³éÏóÀàÖ÷ÒªÓÃÀ´½øÐÐÀàÐÍÒþ²Ø¡£ÎÒÃÇ¿ÉÒÔ¹¹Ôì³öÒ»¸ö¹Ì¶¨µÄÒ»×éÐÐΪµÄ³éÏóÃèÊö£¬µ«ÊÇÕâ×éÐÐΪȴÄܹ»ÓÐÈÎÒâ¸ö¿ÉÄܵľßÌåʵÏÖ·½Ê½¡£Õâ¸ö³éÏóÃèÊö¾ÍÊÇ
³éÏóÀ࣬¶øÕâÒ»×éÈÎÒâ¸ö¿ÉÄܵľßÌåʵÏÖÔò±íÏÖΪËùÓпÉÄܵÄÅÉÉúÀࡣģ¿é¿ÉÒÔ²Ù×÷Ò»¸ö³éÏóÌå¡£ÓÉÓÚÄ£¿éÒÀÀµÓÚÒ»¸ö¹Ì¶¨µÄ³éÏóÌ壬Òò´ËËü¿ÉÒÔÊDz»ÔÊÐíÐ޸ĵģ»
ͬʱ£¬Í¨¹ý´ÓÕâ¸ö³éÏóÌåÅÉÉú£¬Ò²¿ÉÀ©Õ¹´ËÄ£¿éµÄÐÐΪ¹¦ÄÜ¡£ÊìϤOCPµÄ¶ÁÕßÒ»¶¨ÖªµÀ£¬ÎªÁËÄܹ»ÊµÏÖÃæÏò¶ÔÏóÉè¼ÆµÄÒ»¸ö×îºËÐĵÄÔÔòOCP(Open-
Closed Principle)£¬³éÏóÀàÊÇÆäÖеĹؼüËùÔÚ¡£
´ÓÓï·¨¶¨Òå²ãÃæ¿´abstract classºÍ
interface
ÔÚÓï·¨²ãÃ棬Ja
Ïà¹ØÎĵµ£º
JavaỊ̈߳ºÐÂÌØÕ÷-Ô×ÓÁ¿
ËùνµÄÔ×ÓÁ¿¼´²Ù×÷±äÁ¿µÄ²Ù×÷ÊÇ“Ô×ӵĔ£¬¸Ã²Ù×÷²»¿ÉÔÙ·Ö£¬Òò´ËÊÇḬ̈߳²È«µÄ¡£
ΪºÎҪʹÓÃÔ×Ó±äÁ¿ÄØ£¬ÔÒòÊǶà¸öÏ̶߳Ե¥¸ö±äÁ¿²Ù×÷Ò²»áÒýÆðһЩÎÊÌâ¡£ÔÚJava5֮ǰ£¬¿ÉÒÔͨ¹ývolatile¡¢synchronized¹Ø¼ü×ÖÀ´½â¾ö²¢·¢·ÃÎʵݲȫÎÊÌ⣬µ«ÕâÑùÌ«Âé·³¡£
Java5Ö®ºó£¬× ......
°æȨÉùÃ÷£º×ªÔØʱÇëÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕÂÔʼ³ö´¦ºÍ×÷ÕßÐÅÏ¢¼°±¾ÉùÃ÷
http://as112255.blogbus.com/logs/38662785.html
package com.softeem.jbs.lesson4;
import java.util.Random;
/**
* ÅÅÐò²âÊÔÀà
*
* ÅÅÐòËã·¨µÄ·ÖÀàÈçÏ£º
* 1.²åÈëÅÅÐò£¨Ö±½Ó²åÈëÅÅÐò¡¢ÕÛ°ë²åÈëÅÅÐ ......
synchronized£º ͬ²½µÄ
synchronizedÔÚ²Ù×÷ÉÏÓÐÁ½ÖÖÓ°Ïì¶ÔÏóµÄÇé¿ö£º
1) ÔÚij¸ö¶ÔÏóʵÀýÄÚ£¬synchronized method(){}¿ÉÒÔ·ÀÖ¹¶à¸öÏß³Ìͬʱ·ÃÎÊÕâ¸ö¶ÔÏóµÄsynchronized·½·¨£¨Èç¹ûÒ»¸ö¶ÔÏóÓжà¸ösynchronized·½·¨£¬Ö»ÒªÒ»¸öÏ̷߳ÃÎÊÁËÆäÖеÄÒ»¸ösynchronized·½·¨£¬ÆäËüÏ̲߳»ÄÜͬʱ·ÃÎÊÕâ¸ö¶ÔÏóÖÐÈκÎÒ»¸ösynchronized·½·¨£ ......
Android_1.0_eBook_by_tom_kao_2008_10_15.pdf
¡¶AndroidÓ¦Óÿò¼ÜÔÀíÓë³ÌÐòÉè¼Æ36¼¼¡·
±¾書ÍêÕû範例³Ìʽ碼請µ½網Õ¾ÏÂ載:
www.misoo1.com »ò tom-kao.blogspot.com
¸ß煥Ìà Öø(2008 年10 ÔµÚÈý°æ)
misoo.tw@gmail.com
&n ......
½ñÌìÓöµ½Ò»¸öÒªÉú³ÉÒ»¸öÏÂÀÁбí¿òµÄÎÊÌ⣬ÎÒµÄÏë·¨ÊÇ£º½«Êý¾Ý¿âÄÚµÄËùÓÐÊý¾Ý¶¼´æ´¢µ½Ò»¸öListÀïÃ棬ÔÙÔÚǰ̨±éÀúÕû¸ölist¡£
Ö´ÐÐЧ¹ûͼ£º
Ë®¹û
→Æ»¹û
→→Æ»¹ûϵÁÐ1
→→Æ»¹ûϵÁÐ2
→→Æ»¹ûϵÁÐ3
→→Æ»¹ûϵÁÐ4
→Àæ
→ÌÒ×Ó
ѧϰÓÃÆ·
→±Ê
→→Ǧ±Ê ......