Java Medium transient, It is used to declare serialization without being stored .

Example :

package ThreadTest;
* Created with IntelliJ IDEA.
* User: Blank
* Date: 14-3-29
* Time: Afternoon 12:03
import java.util.*; class Logon implements Serializable {
private Date date = new Date();
private String username;
private transient String password;
Logon(String name, String pwd) {
username = name;
password = pwd;
public String toString() {
String pwd =
(password == null) ? "(n/a)" : password;
return "logon info: \n " +
"username: " + username +
"\n date: " + date.toString() +
"\n password: " + pwd;
public static void main(String[] args) {
Logon a = new Logon("Hulk", "myLittlePony");
System.out.println( "logon a = " + a);
try {
ObjectOutputStream o =
new ObjectOutputStream(
new FileOutputStream("Logon.out"));
// Delay:
int seconds = 5;
long t = System.currentTimeMillis()
+ seconds * 1000;
while(System.currentTimeMillis() < t)
// Now get them back:
ObjectInputStream in =
new ObjectInputStream(
new FileInputStream("Logon.out"));
"Recovering object at " + new Date());
a = (Logon)in.readObject();
System.out.println( "logon a = " + a);
} catch(Exception e) {
} ///:~

Output :

from :

JAVA Medium Transient More articles about

  1. About Java Medium transient keyword

    Java Medium transient Keywords are used in serialization , If you use transient Modifying variables , Then the variable is not serialized . The following example creates a Student class , There are three member variables :id,name, ...

  2. java Medium transient Keyword details

    Catalog 1. What is serialization ? 2. Why serialization ? 3. Serialization and transient Use Class serialVersionUID effect 5.transient Summary of key words Preface To be honest, I learned it for a while jav ...

  3. Java Key words in transient Leading to serialization and deserialization

    One :transient( temporary ) keyword 1.transient Keywords can only modify variables , Instead of modifying methods and classes . Be careful , Local variables cannot be transient Keyword modifier . 2. By transient The variable modified by the keyword is not ...

  4. Java Medium transient keyword

    Reproduced in :[lfsf802]( Keyword Introduction As long as an object is implemented Serilizable Interface , This ...

  5. Java Medium transient keyword , Use the summary

    transient Introduction of key words : As long as an object is implemented Serilizable Interface , This object can be serialized ,Java This serialization mode of provides a lot of convenience for developers , You don't have to deal with the specific serialization process , As long as this class implements S ...

  6. java Medium transient key word

    All of the following are from :, Some of them are copied directly . 1. transient The role of The entity class implements Seriliz ...

  7. Java in static/transient,final/volatile explain

    You can define a field by using any of the following modified qualified keywords :final perhaps volatile and / perhaps static and / perhaps transient. If you define a field as final, The compiler will make sure that the field is treated as a constant —— read-only ...

  8. Java Keywords in transient

    First explain Java Object serialization in In the discussion transient Before , It's necessary to find out first Java The meaning of serialization in : Java Serialization of objects in refers to the conversion of objects to be represented as byte sequences , These byte sequences contain the data and information of the object ...

  9. Java in static、final、static final The difference between ( turn )+transient

    explain : Not necessarily accurate , But the quickest way to understand . final: final Can be modified : attribute , Method , class , local variable ( Variable in method ) final The initialization of decorated properties can be done at compile time , Or during the operation period , Cannot be changed after initialization . final ...

Random recommendation

  1. java List and Map Use

    One .MAP package net.xsoftlab.baike; import java.util.HashMap;import java.util.Iterator;import java.uti ...

  2. Get... By program Internet Time A temporary solution without a general procedure

    It's not a complete failure , But there's no universal solution , This universal means that all time servers cannot be universal , Not the operating system . There are many solutions on the Internet , Useful Socket class . or TcpClient class (C#). or UdpClient class , Port available ...

  3. First use InstallShield note

    The company's products need to be packaged and released , Never packed before , The study of packing method is left to me The following is my research , Notes written through recollection . Because I'm not familiar with , There may be mistakes or stupid ways , I hope the experts can correct me , Be deeply grateful . What are some things , And what it means ...

  4. Modeling algorithm ( 11、 ... and )&mdash;&mdash; Goal planning

    Thinking of solving multi objective programming 1. Weighted coefficient method Add a weight coefficient to each goal , Transform the multi-objective model into a single objective model . But when it is difficult to determine a reasonable weight coefficient , To reflect the importance of different goals . 2. Priority method Divide the goals into different categories according to their importance ...

  5. UNITY3D MAC Version cracking

    Baidu online disk download address : Contains ontology and cracking files Let's start with , If it's a company that makes development suggestions to buy genuine . Before, there were a lot of people posted broken ...

  6. CRM Something to pay attention to , Modify field type

    crm If the field type changes , For example, the text type becomes the search type , To create a new name is different from the original one , Never delete the previous field and recreate the original one , That way, if you import to the formal system, you will be unable to import , perform sql Failure , Remember . You can add... After the field name 2, perhaps ...

  7. I have to mention volatile And instruction reordering (happen-before)

    WeChat official account [ Programmer's world ] Author Huang Xiaoxie , Slash the youth , some 985 master , Ali Java R & D Engineer , On 2018 In autumn, I got BAT headlines . NetEase . Didi et al 8 A big factory offer, At present, we are committed to sharing the learning experience of these years . ...

  8. mac Lower installation Brew Warning :Warning: /usr/local/bin is not in your PATH.

    Terminal input command export PATH=/usr/local/bin:$PATH

  9. Apollo Configuration center

    background : At present, our project , All configuration is basically through local properties The file is configured , such as ip Address . port . Various parameters of message middleware and database connection , When we need to switch environments or adjust parameters , We have to modify these configurations manually ...

  10. Spring Source code analysis bean The instantiation principle

    This time I mainly want to write spring bean Instantiation related content . establish spring bean The instance is spring bean The first phase of the life cycle .bean There are several steps in the life cycle of : establish bean Example Give examples ...