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

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); &n


Ïà¹ØÎĵµ£º

JAVA¿ª·¢Õß×ȥµÄ20¸öÓ¢ÎÄÍøÕ¾


 
JAVA¿ª·¢Õß×ȥµÄ20¸öÓ¢ÎÄÍøÕ¾
1.[http://www.javaalmanac.com] – Java¿ª·¢ÕßÄê¼øÒ»ÊéµÄÔÚÏß°æ±¾. ÒªÏë¿ìËٲ鵽ijÖÖJava¼¼ÇɵÄÓ÷¨¼°Ê¾Àý´úÂë, ÕâÊÇÒ»¸ö²»´íµÄÈ¥´¦.
2.[http://www.onjava.com] – O’ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐÐÂÎÄÕÂ.
3.[http://java.sun.com] – ¹Ù·½µÄJava¿ª·¢ÕßÍ ......

Ï£¶ûÅÅÐòËã·¨µÄJAVAʵÏÖ

package Utils.Sort;
/**
*Ï£¶ûÅÅÐò£¬ÒªÇó´ýÅÅÐòµÄÊý×é±ØÐëʵÏÖComparable½Ó¿Ú
*/
public class ShellSort implements SortStrategy
{
       private int[] increment;
       /**
       *ÀûÓÃÏ£¶ûÅÅÐòËã·¨¶ÔÊý×éob ......

¹é²¢ÅÅÐòËã·¨µÄJAVAʵÏÖ

package Utils.Sort;
/**
*¹é²¢ÅÅÐò£¬ÒªÇó´ýÅÅÐòµÄÊý×é±ØÐëʵÏÖComparable½Ó¿Ú
*/
public class MergeSort implements SortStrategy
{
       private Comparable[] bridge;
       /**
       *ÀûÓù鲢ÅÅÐòË ......

¿ìËÙÅÅÐòËã·¨µÄJAVAʵÏÖ

package Utils.Sort;
/**
*¿ìËÙÅÅÐò£¬ÒªÇó´ýÅÅÐòµÄÊý×é±ØÐëʵÏÖComparable½Ó¿Ú
*/
public class QuickSort implements SortStrategy
{
       private static final int CUTOFF = 3;             //µ±ÔªËØÊý´óÓÚ´Ë ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ