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

javaÖеÄclon()ºÍcloneable½Ó¿ÚdzÎö

 The clone( ) method generates a duplicate copy of the object on which it is called. Only classes that implement the Cloneable interface can be cloned.
 
...clone()²úÉúÁËÒ»¸öµ÷ÓÃËüµÄ¶ÔÏóµÄ¸´ÖÆ;Ö»ÓÐʵÏÖÁËCloneable½Ó¿ÚµÄÀà²Å¿ÉÒÔ±»¸´ÖÆ¡£
 
 
The Cloneable interface defines no members. It is used to indicate that a class allows a bitwise copy of an object (that is, a clone ) to be made. If you try to call clone( ) on a class that does not implement Cloneable , a CloneNotSupportedException is thrown. When a clone is made, the constructor for the object being cloned is not called. A clone is simply an exact copy of the original.
 
Cloneable ½Ó¿ÚûÓж¨ÒåÈκγÉÔ±¡£ËüÓÃÀ´Ö¸Ã÷Ò»¸öÀà¿ÉÒÔÖðλ¸´ÖÆÒ»¸ö¶ÔÏó¡£Èç¹ûÄãÊÔͼ¶ÔÒ»¸öûÓÐʵÏÖcloneable½Ó¿ÚµÄÀàµ÷ÓÃclone()·½·¨£¬Ò»¸öCloneNotSupportedException ¾Í»áÅ׳ö¡£ÔÚ¸´ÖÆʱ£¬±»¸´ÖƵĶÔÏóµÄ¹¹ÔìÆ÷²¢Ã»Óб»µ÷Ó᣸´ÖƶÔÏó¾ÍÊÇÔ­À´¶ÔÏóµÄ¿½±´¡£
 
Cloning is a potentially dangerous action, because it can cause unintended side effects. For example, if the object being cloned contains a reference variable called obRef, then when the clone is made, obRef in the clone will refer to the same object as does obRef in the original. If the clone makes a change to the contents of the object referred to by obRef, then it will be changed for the original object, too. Here is another example. If an object opens an I/O stream and is then cloned, two objects will be capable of operating on the same stream. Further, if one of these objects closes the stream, the other object might still attempt to write to it, causing an error.
 
¸´ÖÆÊÇÒ»ÖÖ´æÔÚDZÔÚΣÏÕµÄÐÐΪ£¬ÒòΪËü»áÒýÆðһЩÒâÏë²»µ½µÄ¸º×÷Óá£ÀýÈ磬Èç¹û±»¸´ÖƵĶÔÏó°üº¬Ò»¸öÃûΪ obRef ÒýÓñäÁ¿£¬ÔÚ¸´ÖÆʱ£¬¸´ÖƶÔÏóµÄ obReºÍf Ô­À´¶ÔÏóµÄ obRef ¶¼»áÖ¸Ïòͬһ¸ö¶ÔÏó¡£Èç¹û¸´ÖƶÔÏó¶Ô obRef Ö¸ÏòµÄ¶ÔÏóµÄÄÚÈÝ×ö³öһЩ¸Ä±ä£¬¶ÔÓÚÔ­À´¶ÔÏóÀ´Ëµ£¬Ò²¾ÍÏ൱ÓÚËüÒ²±»¸Ä±äÁË¡£»¹ÓÐÁíÒ»¸öÀý×Ó£¬Èç¹ûÒ»¸ö²Ù×÷I/OÁ÷µÄ¶ÔÏ󱻸´ÖÆÁË£¬ÕâÁ½¸ö¶ÔÏó¶¼ÄܶÔͬһI/OÁ÷½øÐвÙ×÷¡£½øÒ»²½Ëµ£¬Èç¹ûËüÃÇÁ½¸öÖеÄÒ»¸ö¹Ø±ÕÁ


Ïà¹ØÎĵµ£º

java Òì³£Exception ¼¯


<!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:ËÎÌå;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@SimSun&qu ......

JAVAµ÷DLL,.JNI¼¼Êõʵ¼ù

¼øÓÚÅÀ³æ¿ª·¢ÐèÒªÒ»¸öͼƬ½âÎö¹¦Äܵĺ¯Êý£¬µ½ÍøÂçÉϲéÕÒÁËһЩjni·½ÃæµÄÄÚÈÝ£¬²¢×öÁË×Ô¼ºµÄһЩÐ޸ģ¬¾ßÌåÈçÏ£º
   Ä¿Ç°javaÓëdll½»»¥µÄ¼¼ÊõÖ÷ÒªÓÐ3ÖÖ£ºjni£¬jawinºÍjacob¡£Jni£¨Java Native Interface£©ÊÇsunÌṩµÄjavaÓëϵͳÖеÄÔ­Éú·½·¨½»»¥µÄ¼¼Êõ£¨ÔÚwindows\linuxϵͳÖУ¬ÊµÏÖjavaÓënative method»¥µ÷£©¡£ ......

Java Éè¼Æģʽ(12)

Observer
Intent
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
How to
Subject
  
knows its observers. Any number of Observer objects may observe a subject.
  
provides an in ......

һλ»ÝÆÕjavaÑз¢¹¤³Ìʦ²ûÊöjavaÅàѵµÄ¸ÐÑÔ

¹¤×÷ÒѾ­ÓаëÄêÁË£¬Í»È»Ïëдµã¶«Î÷£¬´óѧµÄʱºò¾ÍÓÐдÈռǵÄÏ°¹ß£¬µ«ÊÇ×Ô´ÓÈ¥Java06°àѧϰһֱµ½ÏÖÔÚ¹¤×÷£¬ÂýÂýµÄҲûÓÐʱ¼äȥдÈռǣ¬Ï£Íûͨ¹ýÕâƪÎÄÕÂÄÜÈÃJava˽ÛÓµÄѧµÜѧÃÃÃÇ¿´ÁËÓÐËù°ïÖú¡£
    ÏàÐźܶàͬѧºÜÎÒÒ»Ñù´óËĵÄʱºò¶¼±È½ÏÃÔ㣬ÓÈÆäÊÇÎÒ¶ÁµÄ¼ÆËã»úרҵ£¬ËµÊµ»°´óѧÀïѧµÄºÍÉç»áʵ¼ÊÐèÒªµÄ» ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ