±À¤¶:| ½Õ¸Ñ­û½Òµ{ | Makeup Course | Hypnosis course | English course | NLP training | cissp cisa cism | Àç¾i¾Ç½Òµ{ |

µo·s¸ÜÃD
¥´¦L

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

¥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
class Computer{              public void turnOn(){       }   }

²{¦b¦³¤F¹q¸£³o­ÓÃþ¡A¨º»ò­Ó¤HPC¡Aµ§°O¥»³£¬OÄ~©Ó¥L¡C
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");       }   }

§Ú­Ì¬Ý¨ì¡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¼Ë
class Test{       public void go(Computer computer){            computer.turnOn();       }   }

³o­Ó¤èªk±µ¦¬ªº¬O°òÃþ°Ñ¼Æ¡A·íµM§Ú­Ì¬O¥i¥H§â¤lÃþ¶Ç»¼µ¹¤èªkªº¡A¤]À³¸Ó³o»ò°µ¡C
go(new PC());   go(new NB());

³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
public void go(PC computer){               computer.turnOn();          }       public void go(NB computer){               computer.turnOn();          }

³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


http://big5.ccidnet.com:89/gate/big5/java.ccidnet.com/art/3539/20080903/1562769_1.html


¬ÛÃö·j¯Á¥Ø¿ý: ¹q¸£

TOP

µo·s¸ÜÃD


­«­nÁn©ú¡G¥»°Q½×°Ï¬O¥H§Y®É¤W¸ü¯d¨¥ªº¤è¦¡¹B§@¡A¥»ºô¯¸¹ï©Ò¦³¯d¨¥ªº¯u¹ê©Ê¡B§¹¾ã©Ê¤Î¥ß³õµ¥¡A¤£­t¥ô¦óªk«ß³d¥ô¡C¦Ó¤@¤Á¯d¨¥¤§¨¥½×¥u¥Nªí¯d¨¥ªÌ­Ó¤H·N¨£¡A¨Ã«D¥»ºô¯¸¤§¥ß³õ¡A¥Î¤á¤£À³«H¿à¤º®e¡A¨ÃÀ³¦Û¦æ§PÂ_¤º®e¤§¯u¹ê©Ê¡C©ó¦³Ãö±¡§Î¤U¡A¥Î¤áÀ³´M¨D±M·~·N¨£(¦p¯A¤ÎÂåÀø¡Bªk«ß©Î§ë¸êµ¥°ÝÃD)¡C¥Ñ©ó¥»°Q½×°Ï¨ü¨ì¡u§Y®É¤W¸ü¯d¨¥¡v¹B§@¤è¦¡©Ò³W­­¡A¬G¤£¯à§¹¥þºÊ¹î©Ò¦³¯d¨¥¡A­YŪªÌµo²{¦³¯d¨¥¥X²{°ÝÃD¡A½ÐÁpµ¸§Ú­Ì¡C¥»°Q½×°Ï¦³Åv§R°£¥ô¦ó¯d¨¥¤Î©Úµ´¥ô¦ó¤H¤h¤W¸ü¯d¨¥¡A¦P®É¥ç¦³¤£§R°£¯d¨¥ªºÅv§Q¡C¤Á¤Å¼¶¼g²Ê¨¥Â©»y¡B½ÚÁ½¡B´è¬V¦â±¡¼É¤O©Î¤H¨­§ðÀ»ªº¨¥½×¡A·q½Ð¦Û«ß¡C¥»ºô¯¸«O¯d¤@¤Áªk«ßÅv§Q¡C


Copyright 1997- Xocat. All Right Reserved.