Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÉîÈëdz³öJava clone¼¼Êõ

¡¡ÕâÊÇclone¼¼Êõ½éÉܵĵÚһƪ¡£±¾ÆªÖ÷Òª½éÉܶÔÏóclone¼¼ÊõµÄ»ù±¾ÖªÊ¶¡£
Clone»ù±¾ÖªÊ¶´¢±¸
ÔÚJavaÀïÌáµ½clone¼¼Êõ£¬¾Í²»Äܲ»Ìájava.lang.Cloneable½Ó¿ÚºÍº¬ÓÐclone·½·¨µÄObjectÀà¡£ËùÓоßÓÐclone¹¦ÄܵÄÀ඼ÓÐÒ»¸öÌØÐÔ£¬ÄǾÍÊÇËüÖ±½Ó»ò¼ä½ÓµØʵÏÖÁËCloneable½Ó¿Ú¡£·ñÔò£¬ÎÒÃÇÔÚ³¢ÊÔµ÷ÓÃclone£¨£©·½·¨Ê±£¬½«»á´¥·¢CloneNotSupportedExceptionÒì³£¡£ÏÂÃæÎÒÃÇͨ¹ý¶ÔObjectÀàµÄ²¿·ÖÔ´ÂëµÄ·ÖÎö£¬À´·¢ÏÖºÍÀí½âÕâÒ»ÌØÐÔ¡£Çë¿´JDKÖÐObject# clone()·½·¨µÄÔ´Â룺
/*
…………
* @return a clone of this instance.
* @exception? CloneNotSupportedException? if the object's class does not
*support the Cloneable interface. Subclasses
*that override the clone method can also
* throw this exception to indicate that an instance cannot
*be cloned.
* @see java.lang.Cloneable
*/
protected native Object clone() throws CloneNotSupportedException;
Õâ¶ÎÔ´ÂëµÄ@exception²¿·ÖµÄÃèÊöÄÚÈÝ֤ʵÁËÉÏÎĹØÓÚclone¶ÔÏóÌØÐÔÂ۶ϵÄÕýÈ·ÐÔ¡£ËüÃ÷È·Ö¸³ö¶ÔÏóÀà±ØÐëÖ§³ÖCloneable½Ó¿Ú£¬·ñÔò¼´Ê¹ÅÉÉúÀา¸ÇÁËObject#clone()·½·¨£¬Ò²Í¬Ñù»áÅ׳öCloneNotSupportedExceptionÕâ¸öÒì³£¡£¹ØÓÚ¸²¸Çclone()·½·¨£¬ºóÐøÎÄÕ½«»áÓÃרÃÅƪ·ù½øÐбȽÏÏêϸµÄ·ÖÎö.
ÔÚÉÏһƪÖУ¬½éÉÜÁËjavaÀïcloneµÄ»ù±¾ÖªÊ¶¡£±¾Æª½«×ÅÖØÃèÊöÈçºÎʵÏÖclone¡£
l cloneµÄʵÏÖ
1.ʵÏÖCloneable½Ó¿Ú
ͨ¹ýÉÏһƪµÄ½éÉÜ£¬ÎÒÃÇÖªµÀ£¬Ò»¸öÀàÈôÒª¾ß±¸clone¹¦ÄÜ£¬¾Í±ØÐëʵÏÖCloneable½Ó¿Ú¡£×öµ½ÕâÒ»²½£¬clone¹¦ÄÜÒѾ­»ù±¾ÊµÏÖÁË¡£Clone¹¦ÄܶÔÎÒÃÇÀ´Ëµ£¬×îÖ÷ÒªµÄ»¹ÊÇÒªÄܹ»Ê¹ÓÃËü¡£ÄÇôÎÒÃÇÈçºÎ²ÅÄÜʹÓÃclone¹¦ÄÜÄØ£¿´ð°¸ÊǸ²¸ÇObject#clone()·½·¨¡£
2. ¸²¸ÇObject#clone()·½·¨
ΪʲôÐèÒª¸²¸ÇObject#clone()·½·¨£¿ÕâÀïµÃÔٴδÓjdkÔ´Âë˵Æð¡£JDKÖÐObject# clone()·½·¨µÄÔ­ÐÍÊÇ£º
protected native Object clone() throws CloneNotSupportedException;
ÊÇ·ñ×¢Òâµ½£¬ÕâÀïclone()·½·¨ÐÞÊηûÊÇprotected£¬¶ø²»ÊÇpublic¡£ÕâÖÖ·ÃÎʵIJ»¿É¼ûÐÔʹµÃÎÒÃǶÔObject#clone()·½·¨²»¿É¼û¡£ÏàÐŶÁÕßÒÑÃ÷°×ΪʲôҪ¸²¸ÇObject#clone()·½·¨¡£¶øÇÒ£¬¸²¸ÇµÄ·½·¨µÄÐÞÊηû±ØÐëÊÇpublic£¬Èç¹û»¹±£ÁôΪprotected£¬¸²¸Ç½«±äµÃûÓÐʵ¼ÊÒâÒå¡£ÏÂÃæ¾ÙÒ»¸ö¾ßÓÐclone¹¦Äܵļòµ¥µÄÀý×Ó£º
/*
* ¾ßÓÐclone¹¦ÄܵÄÀàµÄÀý×Ó
*/
public class CloneableObjExampl


Ïà¹ØÎĵµ£º

ÕÐƸÒøÐÐÏîÄ¿JAVA¿ª·¢¹¤³Ìʦ

     Ö÷ÒªÊÇ×ö¸÷µØÒøÐеÄÍâΧϵͳ£¬ÀýÈçµç×Ó»ãƱ¡¢·´Ï´Ç®ÏµÍ³µÈ£¬ÓÐÐËȤµÄ¿ÉÒÔ¼ÓÎÒQQ£¨429177125£©¾ßÌåÁÄ£¬ÃæÊԵصãÔÚ±±¾©Êк£µíÇøκ¹«´å¡£
¾ßÌåÈçÏ£º
Java¹¤×÷¾­Ñ飬2-3Äê
         ÈíÐÔÒªÇ󣺠ÒÔϹ¤×÷¾­ÑéÖ®Ò»ÕßÓÅÏÈ¡£1¡¢ ÓÐÒøÐй¤×÷¾­ ......

ʹÓÃԭ֭ԭζµÄJava ÓïÑÔ

±¾ÎÄÕª×Ô£º http://www.ibm.com/developerworks/cn/java/j-noaccent.html
ѧϰһÖÖеıà³ÌÓïÑÔ±ÈѧϰеĿÚÍ·ÓïÑÔÒªÈÝÒ׵öࡣȻ¶ø£¬ÔÚÕâÁ½ÖÖѧϰ¹ý³ÌÖУ¬¶¼Òª¸¶³ö¶îÍâµÄŬÁ¦È¥Ñ§Ï°²»´ø¿ÚÒôµØ˵ÐÂÓïÑÔ¡£Èç¹ûÄúÊìϤ C »ò C++£¬ÄÇôѧϰ Java ÓïÑÔ²¢²»À§ÄÑ£¬Õâ¾ÍÏñÊÇ»á˵ÈðµäÓïµÄÈËȥѧµ¤ÂóÓïÒ»Ñù¡£ÓïÑÔËäÓв»Í¬£¬µ«Óֱ˴˻ ......

UVAOj javaÊäÈëÊä³ö


/**
* ### Õæ難µÄ題Ä¿: ¹·Æ¨ÑÝËã·¨ (測資ºÜ機車)
* 測驗結¹û: x.xx0 ms
* 測驗ÈÕÆÚ: 200y-mm-dd
* @author Raymond Wu (Сè°Íè)
*/
public class Main {
 
  // 輸Èë緩衝區 (緩衝¿Õ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ