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

javaÖеĹؼü×Ö£¨transient£©

transientÕâ¸ö¹Ø¼ü×Ö²¢²»³£¼û£¬Ö÷ÒªÓ¦ÓÃÔÚjavaµÄÐòÁл¯·½Ãæ¡£ÕâÀïÎÒÔÙ¶à˵£¬×ªÒ»ÆªÀÏÍâµÄÎÄÕ£¬ºÜÉú¶¯£¬ÐÀÉÍ°É
 
Be Careful With Transient Data
Java's serialization provides an elegant, and easy to use mechanism for making an object's state persistent. While controlling object serialization, we might have a particular object data member that we do not want the serialization mechanism to save.
To turn off serialization on a certain field of an object, we tag that field of the class of our object with the Java's "transient" keyword. This, to low-level parts of the Java virtual machine, is an indication that the transient variable is not part of the persistent state of an object.
First, let's have some backgrounder code with Java's serialization.
Suppose we define a class as:
public class LoggingInfo implements java.io.Serializable
{
    private Date loggingDate = new Date();
    private String uid;
    private transient String pwd;
   
    LoggingInfo(String user, String password)
    {
        uid = user;
        pwd = password;
    }
    public String toString()
    {
        String password=null;
        if(pwd == null)
        {
        password = "NOT SET";
        }
        else
        {
            password = pwd;
        }
        return "logon info: \n   " + "user: " + uid +
            "\n  


Ïà¹ØÎĵµ£º

JAVAÅÀ³æ

ÕâÊÇÒ»¸öwebËÑË÷µÄ»ù±¾³ÌÐò£¬´ÓÃüÁîÐÐÊäÈëËÑË÷Ìõ¼þ£¨ÆðʼµÄURL¡¢´¦ÀíurlµÄ×î´óÊý¡¢ÒªËÑË÷µÄ×Ö·û´®),
Ëü¾Í»áÖð¸ö¶ÔInternetÉϵÄURL½øÐÐʵʱËÑË÷,²éÕÒ²¢Êä³öÆ¥ÅäËÑË÷Ìõ¼þµÄÒ³Ãæ¡£ Õâ¸ö³ÌÐòµÄÔ­ÐÍÀ´×Ô¡¶java±à³ÌÒÕÊõ¡·£¬
ΪÁ˸üºÃµÄ·ÖÎö£¬Õ¾³¤È¥µôÁËÆäÖеÄGUI²¿·Ö£¬²¢ÉÔ×÷ÐÞ¸ÄÒÔÊÊÓÃjdk1.5¡£ÒÔÕâ¸ö³ÌÐòΪ»ù´¡£¬¿ÉÒÔд³öÔÚ» ......

java¶àÏß³ÌÀý×Ó

package debug;import java.io.*;import java.lang.Thread;class MyThread extends Thread{  public int x = 0;  public void run(){    System.out.println(++x);  }}class R implements Runnable{  private int x = 0;  public void run(){    System.out.printl ......

JAVA¶àÏß³Ì

package debug;import java.io.*;import java.lang.Thread;class MyThread extends Thread{  public int x = 0;  public void run(){    System.out.println(++x);  }}class R implements Runnable{  private int x = 0;  public void run(){    System.out.printl ......

JAVAʵÏÖµÄħ·½

δÍê³É ´ýÍêÉÆ
public class MagicCube {
/**
* Áù¸öÃæµÄϱêÖµ
* ¡õ5
* ¡õ¡õ¡õ¡õ 1234 ÕâËĸöÁ¬ÌåÕý·½ÐÎÏòºó˳ʱÕë°üΧ ÐγÉͲ״ È»ºó °Ñ5ºÍ6¿ÛÉÏ ¾ÍÐγÉÕý·½Ìå
* ¡õ6
*/
public static void main(String[] args) {
MagicCube mb = new MagicCube();
int i = 0;
for (Face f : mb.faces ......

½«Java¶ÔÏó´æ´¢µ½OracleÊý¾Ý¿âÖÐ

 ¶ÔÏó³Ö¾Ã»¯£¬Ò²¾ÍÊÇ¿ÉÒÔ°ÑÕâ¸ö¶ÔÏóÓÀÔ¶µÄ±£´æÆðÀ´£¬ÕâÀïµÄ±£´æ²»½öÊǶÔÏó±¾Éí£¬»¹°üÀ¨ËûµÄÊôÐÔºÍËùÒÀÀµµÄÆäËûÀࡣͨ³££¬¶ÔÏó¿ÉÒԳ־û¯µ½Îļþ»òÕßÊÇÊý¾Ý¿âÖС£ÎÒÕâÀïÖ»½éÉÜÈçºÎ½«¶ÔÏó´æ´¢µ½Êý¾Ý¿âÖС£Ç¡ÇÉOracleÊý¾Ý¿âΪÎÒÃÇÌṩÁËÕâÑùµÄ·½±ã¡£
   ÔÚOracleÖУ¬ÓÐÒ»ÖÖblogµÄ×Ö¶ÎÀàÐÍ£¬ËüÊÇÓÃÀ´´æ´¢´óÁ¿µÄ¶ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ