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

javaÐòÁл¯(Serializable)µÄ×÷Óúͷ´ÐòÁл¯

ÕâÀïתÔØһƪ½²½âjavaÐòÁл¯(Serializable)ºÍ·´ÐòÁл¯·½ÃæµÄ¸Ð¾õºÜºÃµÄÎÄÕ¡£
1¡¢ÐòÁл¯ÊǸÉʲôµÄ£¿
¼òµ¥Ëµ¾ÍÊÇΪÁ˱£´æÔÚÄÚ´æÖеĸ÷ÖÖ¶ÔÏóµÄ״̬£¨Ò²¾ÍÊÇʵÀý±äÁ¿£¬²»ÊÇ·½·¨£©£¬²¢ÇÒ¿ÉÒ԰ѱ£´æµÄ¶ÔÏó״̬ÔÙ¶Á³öÀ´¡£ËäÈ»Äã¿ÉÒÔÓÃÄã×Ô¼ºµÄ¸÷ÖÖ¸÷ÑùµÄ·½·¨À´±£ ´æobject states£¬µ«ÊÇJava¸øÄãÌṩһÖÖÓ¦¸Ã±ÈÄã×Ô¼ººÃµÄ±£´æ¶ÔÏó״̬µÄ»úÖÆ£¬ÄǾÍÊÇÐòÁл¯¡£
2¡¢Ê²Ã´Çé¿öÏÂÐèÒªÐòÁл¯
a£©µ±ÄãÏë°ÑµÄÄÚ´æÖеĶÔÏó״̬±£´æµ½Ò»¸öÎļþÖлòÕßÊý¾Ý¿âÖÐʱºò£»
b£©µ±ÄãÏëÓÃÌ×½Ó×ÖÔÚÍøÂçÉÏ´«ËͶÔÏóµÄʱºò£»
c£©µ±ÄãÏëͨ¹ýRMI´«Êä¶ÔÏóµÄʱºò£»
3¡¢µ±¶ÔÒ»¸ö¶ÔÏóʵÏÖÐòÁл¯Ê±£¬¾¿¾¹·¢ÉúÁËʲô£¿
ÔÚûÓÐÐòÁл¯Ç°£¬Ã¿¸ö±£´æÔڶѣ¨Heap£©ÖеĶÔÏó¶¼ÓÐÏàÓ¦µÄ״̬£¨state£©£¬¼´ÊµÀý±äÁ¿£¨instance ariable£©±ÈÈ磺
java ´úÂë
Foo  myFoo = new Foo();
myFoo .setWidth(37);
myFoo.setHeight(70);
µ± ͨ¹ýÏÂÃæµÄ´úÂëÐòÁл¯Ö®ºó£¬MyFoo¶ÔÏóÖеÄwidthºÍHeightʵÀý±äÁ¿µÄÖµ£¨37£¬70£©¶¼±»±£´æµ½foo.serÎļþÖУ¬ÕâÑùÒÔºóÓÖ¿ÉÒÔ°ÑËü ´ÓÎļþÖжÁ³öÀ´£¬ÖØÐÂÔÚ¶ÑÖд´½¨Ô­À´µÄ¶ÔÏó¡£µ±È»±£´æʱºò²»½ö½öÊDZ£´æ¶ÔÏóµÄʵÀý±äÁ¿µÄÖµ£¬JVM»¹Òª±£´æһЩСÁ¿ÐÅÏ¢£¬±ÈÈçÀàµÄÀàÐ͵ÈÒÔ±ã»Ö¸´Ô­À´µÄ¶Ô Ïó¡£
java ´úÂë
FileOutputStream fs = new FileOutputStream("foo.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(myFoo);
4¡¢ÊµÏÖÐòÁл¯£¨±£´æµ½Ò»¸öÎļþ£©µÄ²½Öè
a¡¢Make a FileOutputStream
java ´úÂë
FileOutputStream fs = new FileOutputStream(“foo.ser”);
b¡¢Make a ObjectOutputStream
java ´úÂë
ObjectOutputStream os =  new ObjectOutputStream(fs);
c¡¢write the object
java ´úÂë
os.writeObject(myObject1);
os.writeObject(myObject2);
os.writeObject(myObject3);
d¡¢ close the ObjectOutputStream
java ´úÂë
os.close();
5¡¢¾ÙÀý˵Ã÷
Java´úÂë
package com.hotye.dchaoxiong.serializabletest;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class Box implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private int width;
private int height;
private String&


Ïà¹ØÎĵµ£º

javaÖÐÈçºÎʹÓÃamcharts


×î½ü¹«Ë¾Åöµ½ÐèÒªÓÃͼ±íµÄÐÎʽÏÔʾһЩÊý¾Ý£¬ÎҾͿªÊ¼µ½ÍøÉϲéѯ£¬²éµ½ÁËjfreechartºÍamcharts,ÕâÁ½ÕßÎÒ¶¼ÊµÏÖ¹ýÁË£¬jfreechart×îºóÉú³ÉͼƬ£¬µ«ÊÇͼƬЧ¹û²»ÊÇÎÒÏëÒªµÄ£¬È»ºóÓÖÑо¿amcharts ËüµÄЧ¹ûȷʵºÜºÃ£¬¶øÇÒ¹Ù·½ÍøÕ¾ÉÏ»¹ÓкÃЩÀý×ӿɹ©ÏÂÔØ£¬ÍøÖ·ÊÇ:www.amcharts.com
£¨ÏëÒªÍê³ÉÒ»¸öamchartsͼÐÎÐèÒªswfobjects. ......

javaºÍc#µÄËø

ÒªÔÚJavaÖлñµÃijһ±äÁ¿µÄËø£¬±ØÐëÔÚ´úÂëµÄÊ×β¶þ¶Ë¼ÓÉÏsynchronized¹Ø½¡×Ö£¬Ö¸Ã÷ÐèÒª»ñµÃËøµÄ¶ÔÏó¡£Ò»µ©Ï߳̿ªÊ¼Ö´ÐÐsynchronized¿éÖеĴúÂ룬Ëü¾Í»ñµÃÁ˶ÔÕâÒ»¶ÔÏóµÄËøµÄ¿ØÖÆȨ¡£Í¬Ñù£¬Ò»µ©Ïß³ÌÒѾ­À뿪ÁËsynchronized¿é£¬ËüÒ²½«ÊÍ·ÅÕâÒ»¶ÔÏóµÄËø¡£ÎÒÃÇÒѾ­ÖªµÀ£¬C#Ò²ÓÐÒ»¸öÏàËƵı»³Æ×÷lockµÄ¹Ø½¡×Ö¡£³ýÁËlockÕâ¸ö¹Ø½¡×Ö ......

¹ØÓÚjavaµÄ¶à̬

ÖØÔØ£º·½·¨ÃûÏàͬ ·µ»ØÀàÐͺͲÎÊýÖÁÉÙÓÐÒ»Ïͬ£¨²ÎÊý°üÀ¨ÀàÐÍ ºÍ ÊýÁ¿£©
ÖØд£º·¢ÉúÔÚ×ÓÀà ·½·¨Ãû ·µ»ØÀàÐÍ ²ÎÊý¶¼Ïàͬ Ö»ÊǰѸ¸ÀàµÄ´Ë·½·¨ÖØÐÂд¶øÒÑ
Ò»Ö±ÒÔÀ´ÎÒ¶ÔFacther f = new Son()ÕâÑùµÄÒýÓñäÁ¿ÒýÓÃ×ÓÀàµÄʵÀý¶¼²»ÊǺܶ®¡£
»¹ÓоÍÊÇÏòÉÏÏòÏÂתÐÍ
È磺Animal animal = new Dog() // ÒýÓñäÁ¿ÒýÓÃÁËÀ´×Ô×ÓÀàµÄÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ