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

java ÐòÁл¯

¶ÔÏóÐòÁл¯(Serializable)ÊÇÖ¸½«¶ÔÏóת»»Îª×Ö½ÚÐòÁеĹý³Ì£¬¶ø·´ÐòÁл¯ÔòÊǸù¾Ý×Ö½ÚÐòÁлָ´¶ÔÏóµÄ¹ý³Ì¡£
ÐòÁл¯Ò»°ãÓÃÓÚÒÔϳ¡¾°£º
1.ÓÀ¾ÃÐÔ±£´æ¶ÔÏ󣬱£´æ¶ÔÏóµÄ×Ö½ÚÐòÁе½±¾µØÎļþÖУ»
2.ͨ¹ýÐòÁл¯¶ÔÏóÔÚÍøÂçÖд«µÝ¶ÔÏó£»
3.ͨ¹ýÐòÁл¯ÔÚ½ø³Ì¼ä´«µÝ¶ÔÏó¡£
¶ÔÏóËùÊôµÄÀà±ØÐëʵÏÖSerializable»òÊÇExternalizable½Ó¿Ú²ÅÄܱ»ÐòÁл¯¡£¶ÔʵÏÖÁËSerializable½Ó¿ÚµÄÀ࣬ÆäÐòÁл¯Óë·´ÐòÁл¯²ÉÓÃĬÈϵÄÐòÁл¯·½Ê½£¬Externalizable½Ó¿ÚÊǼ̳ÐÁËSerializable½Ó¿ÚµÄ½Ó¿Ú£¬ÊǶÔSerializable µÄÀ©Õ¹£¬ÊµÏÖÁËExternalizable½Ó¿ÚµÄÀàÍêÈ«×Ô¼º¿ØÖÆÐòÁл¯Óë·´ÐòÁл¯ÐÐΪ¡£
Java.io.ObjectOutputStream´ú±í¶ÔÏóÊä³öÁ÷£¬Æä·½·¨writeObject(Object obj)¿ÉÒÔʵÏÖ¶ÔÏóµÄÐòÁл¯£¬½«µÃµ½µÄ×Ö½ÚÐòÁÐдµ½Ä¿±êÊä³öÁ÷ÖС£Java.io.ObjectInputStream´ú±í¶ÔÏóÊäÈëÁ÷£¬Æä readObject()·½·¨ÄÜ´ÓÔ´ÊäÈëÁ÷ÖжÁÈ¡×Ö½ÚÐòÁУ¬½«Æä·´ÐòÁл¯Îª¶ÔÏ󣬲¢½«Æä·µ»Ø¡£
JavaµÄÐòÁл¯»úÖÆÖ»ÐòÁл¯¶ÔÏóµÄÊôÐÔÖµ£¬¶ø²»»áÈ¥ÐòÁл¯Ê²Ã´ËùνµÄ·½·¨¡£ÆäʵÕâ¸öÎÊÌâ¼òµ¥Ë¼¿¼Ò»Ï¾ͿÉÒÔ¸ãÇå³þ£¬·½·¨ÊDz»´ø״̬µÄ£¬¾ÍÊÇһЩָÁָÁîÊDz»ÐèÒªÐòÁл¯µÄ£¬Ö»ÒªÄãµÄJVM classloader¿ÉÒÔloadµ½Õâ¸öÀ࣬ÄÇôÀà·½·¨Ö¸Áî×ÔÈ»¾Í¿ÉÒÔ»ñµÃ¡£ÐòÁл¯ÕæÕýÐèÒª±£´æµÄÖ»ÊǶÔÏóÊôÐÔµÄÖµ£¬ºÍ¶ÔÏóµÄÀàÐÍ¡£
ÐòÁл¯ÔËÐÐʱʹÓÃÒ»¸ö³ÆΪ serialVersionUID µÄ°æ±¾ºÅÓëÿ¸ö¿ÉÐòÁл¯ÀàÏà¹ØÁª£¬¸ÃÐòÁкÅÔÚ·´ÐòÁл¯¹ý³ÌÖÐÓÃÓÚÑéÖ¤ÐòÁл¯¶ÔÏóµÄ·¢ËÍÕߺͽÓÊÕÕßÊÇ·ñΪ¸Ã¶ÔÏó¼ÓÔØÁËÓëÐòÁл¯¼æÈݵÄÀà¡£Èç¹û½ÓÊÕÕß¼ÓÔصĸöÔÏóµÄÀàµÄ ¿ÉÐòÁл¯Àà¿ÉÒÔͨ¹ýÉùÃ÷ÃûΪ "serialVersionUID" µÄ×ֶΣ¨¸Ã×ֶαØÐëÊǾ²Ì¬ (static)¡¢×îÖÕ (final) µÄ long ÐÍ×ֶΣ©ÏÔʽÉùÃ÷Æä×Ô¼ºµÄ serialVersionUID£º ½¨ÒéÐèÒªÐòÁл¯µÄ¶ÔÏó¶¼ÉùÃ÷×Ô¼ºµÄÐòÁл¯id£¬ÒòΪjava ĬÈϵÄÐòÁл¯id µÄÉú³ÉÔÚ ÐòÁл¯·½ºÍ·´ÐòÁл¯·½Éú³ÉµÄÖµ¿ÉÄܲ»Ò»Ö¡£
Èç¹ûÐòÁл¯ÀàµÄÓë·´ÐòÁл¯À಻һÑù»áÅ×Òì³£
java.lang.ClassCastException: com.taobao.serialize.test.DomainObject cannot be cast to com.taobao.serialize.test.DomainObject_2
Èç¹ûÐòÁл¯ÀàµÄÓë·´ÐòÁл¯ÀàµÄ ÐòÁл¯id ²»Ò»Ñù£¬Ôò»áÅ×Òì³£
java.io.InvalidClassException: com.taobao.serialize.test.DomainObject; local class incompatible: stream classdesc serialVersionUID = 697337918497451172, local class serialVersionUID = 697337918497451171
Ö»ÒªÐòÁл¯id Ò»Ñù£¬£¬ÐòÁл¯ÀàÃûÒ»Ñù£¬ÐòÁл¯µÄÐÅÏ


Ïà¹ØÎĵµ£º

ÈçºÎÔÚjava swing/awtÖе¥»÷ÓÒ¼üµ¯³öÒ»¸ö²Ëµ¥(ת)

ºÜ¶àÈ˶¼ÖªµÀÔÚswingÖмÓÈëjPopupMenu×é¼þºó¿ÉÒÔÔÚÊó±êµÄÇý¶¯ÏÂ̽³öÒ»¸ö²Ëµ¥£¬µ«ÊÇ£¬Èç¹ûÓÃÒ»°ã×ö·¨£¬ÔÚ½çÃæÉϵ¥»÷×ó¼üÒ²»áµ¯³ö²Ëµ¥£¬ÄÇôÓÐûÓа취ÔÚÖ»Óе¥»÷ÓÒ¼ü²Åµ¯³ö²Ëµ¥ÄØ£¿ÆäʵֻÊÇÓõ½ÁËÒ»¸öС¼¼ÇÉ¡£ ÄãµÄµ¯³öÊó±ê²Ëµ¥Êó±êÇý¶¯Ñ¡Ôñ MouseReleased È»ºóÔÙÔÚ¼àÌýʼþµÄ·½·¨ÖмÓÈëÏÂÃæµÄ´úÂë¾Í¿ÉÒÔÁË£º if(evt.isPop ......

javaµÄÁ½ÖÖ¶à̬

     1. JavaÖгýÁËstaticºÍfinal·½·¨Í⣬ÆäËûËùÓеķ½·¨¶¼ÊÇÔËÐÐʱ°ó¶¨µÄ¡£private·½·¨¶¼±»Òþʽָ¶¨ÎªfinalµÄ£¬Òò´ËfinalµÄ·½·¨²»»áÔÚÔËÐÐʱ°ó¶¨¡£µ±ÔÚÅÉÉúÀàÖÐÖØд»ùÀàÖÐstatic¡¢final¡¢»òprivate·½·¨Ê±£¬ÊµÖÊÉÏÊÇ´´½¨ÁËÒ»¸öеķ½·¨¡£
     2.ÔÚÅÉÉúÀàÖУ¬¶ÔÓÚ»ùÀàÖеÄpr ......

java±àÂë¹æ·¶_ÉùÃ÷ºÍÓï¾ä

1.       ÉùÃ÷(Declarations)
5.1  ÿÐÐÉùÃ÷±äÁ¿µÄÊýÁ¿(Number Per Line)
ÍƼöÒ»ÐÐÒ»¸öÉùÃ÷£¬ÒòΪÕâÑùÒÔÀûÓÚдעÊÍ¡£Ò༴£¬
int level; // indentation level
int size; // size of table
ÒªÓÅÓÚ£¬
int level, size;
²»Òª½«²»Í¬ÀàÐͱäÁ¿µÄÉùÃ÷·ÅÔÚͬһÐУ¬ÀýÈ磺
int foo, foo ......

java collection½Ó¿Ú


1¡¢Collection ºÍ CollectionsµÄÇø±ð¡£
CollectionsÊǸöjava.utilϵÄÀ࣬Ëü°üº¬Óи÷ÖÖÓйØjava¼¯ºÏ²Ù×÷µÄ¾²Ì¬·½·¨¡£ 
CollectionÊǸöjava.utilϵĽӿڣ¬ËüÊǸ÷ÖÖjava¼¯ºÏ½á¹¹µÄ¸¸½Ó¿Ú
2¡¢List, Set, MapÊÇ·ñ¼Ì³Ð×ÔCollection½Ó¿Ú? List£¬SetÊÇ Map²»ÊÇ
3¡¢ArrayListºÍVectorµÄÇø±ð¡£
(1).ͬ²½ÐÔ:VectorÊÇÏß³Ì ......

Java´úÂë¼ì²â¹¤¾ßPMD¹æÔò¼¯·­Òë


<!--
/* Font Definitions */
@font-face
{font-family:ËÎÌå;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
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:Verdana;
panose ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ