±À¤¶:| Web Hosting | ¥~½æ¨t²Î | Server colocation | Web Shop System | Makeup course |

¬d¬Ý§¹¾ãª©¥»: ¥N½X²³æ´y­z ªì¾ÇJava»y¨¥¤§¦hºAªìÅéÅç

ªá¤§¼y¦¸ 2008-9-5 23:32

¥N½X²³æ´y­z ªì¾ÇJava»y¨¥¤§¦hºAªìÅéÅç

¥»¤å­±¦VJavaªì¾ÇªÌ¡A§Ú­Ì¦b±Ð§÷¤W¸g±`·|¬Ý¨ìJava¬O¦hºAªº¡A¥i¬O¤@¯ëªº±Ð¬ì®Ñ¥u°±¯d¦b²z½×¤W¡A«Ü¤Ö¦³¹ê»Ú¾Þ§@¡C²{¦b§â¦hºA­Ó·§©À¥Î¥N½X²³æ´y­z¤@¤U¡A¥Ñ©ó¥»¤H¤ô·Ç¦³­­¡A©Ò¥HÃø§K¦³¤£¨¬¤§³B¡C ­º¥ý§Ú­Ì¦³³o¼Ë´X­ÓÃþ¡A¹q¸£¡A­Ó¤H¹q¸£¡Aµ§°O¥»¹q¸£¡C [table=400][tr][td]class Computer{              public void turnOn(){       }   }[/td][/tr][/table]
²{¦b¦³¤F¹q¸£³o­ÓÃþ¡A¨º»ò­Ó¤HPC¡Aµ§°O¥»³£¬OÄ~©Ó¥L¡C [table=400][tr][td]class PC extends Computer{       public void turnOn(){           System.out.println("PC has turn on");       }   }     class NB extends Computer{       public void turnOn(){           System.out.println("NB has turn on");       }   }[/td][/tr][/table]
§Ú­Ì¬Ý¨ì¡A¨C­ÓÃþ³£¦³¤@­Ó turnOn()¤èªk¡A¦Ó¦b¤÷Ãþ¤¤³o­Ó¤èªk¬OªÅªº¡A¤lÃþ¤¤¦U¦Û¦³¤£¦Pªº¹ê²{¡A¨ì³o¸Ì¥i¯àÁÙ¤£¤Ó©úÅã¡C¦pªG¦³¥t¥~¤@­Ó¤èªk¡A­n±µ¨ü³o¨ÇÃþ§@¬°°Ñ¼Æ¡A´N¹³³o¼Ë [table=400][tr][td]class Test{       public void go(Computer computer){            computer.turnOn();       }   }[/td][/tr][/table]
³o­Ó¤èªk±µ¦¬ªº¬O°òÃþ°Ñ¼Æ¡A·íµM§Ú­Ì¬O¥i¥H§â¤lÃþ¶Ç»¼µ¹¤èªkªº¡A¤]À³¸Ó³o»ò°µ¡C [table=400][tr][td]go(new PC());   go(new NB());[/td][/tr][/table]
³o¼Ë¥L´N·|¥h½Õ¥Î¨ãÅé¤lÃþªºturnOn()¤èªk¡A©Ò¥H³o¨â¦¸½Õ¥Îªº¿é¥X¬O¤£¤@¼Ëªº.¦pªG¤£¥Î°òÃþ§@¬°°Ñ¼Æ,§Ú­Ì·Q½Õ¥Î¨C­Ó¤lÃþªºturnOn()¤èªk¡A¨º»ò´N­n¨Ç¨â­Ó¤èªkÅé¤@¼Ëªºgo()¦Ó±µ¦¬¤£¦Pªº°Ñ¼Æªº­«¸ü¡C [table=400][tr][td]public void go(PC computer){               computer.turnOn();          }       public void go(NB computer){               computer.turnOn();          }[/td][/tr][/table]
³o¼Ë¨Ç¤]¬O¥¿½Tªº¡A¦ý¬O³o¼Ë·|²£¥Í«Ü¦h­«´_¥N½X¡A¦Ó¥B¤]¤£©öºûÅ@¡A·íµM³o¥u¬O¦hºA¤¤³Ì°ò¥»ªº¤@­Ó³¡¤À¡AJava¦hºA¾÷¨îÁÙ¦³«Ü¦h¯S©Ê¡AÃö©ó³o¨Ç«Øij¤j®a¬Ý¬Ý java½sµ{«ä·Q(think in java)³o¥»®Ñ¡AùØ­±Á¿ªº«Ü¸Ô²Ó¡A³o¸Ì¥u¬O«Ü²³æªº´y­z¤F¤@¤U¡AÁÙ±æ­Ó¦U¦ì°ª¤â¤£­n¨£¯º¡C


[url=http://big5.ccidnet.com:89/gate/big5/java.ccidnet.com/art/3539/20080903/1562769_1.html]http://big5.ccidnet.com:89/gate/big5/java.ccidnet.com/art/3539/20080903/1562769_1.html[/url]
­¶: [1]
¬d¬Ý§¹¾ãª©¥»: ¥N½X²³æ´y­z ªì¾ÇJava»y¨¥¤§¦hºAªìÅéÅç