Regarding the transient modifier and serialization in Java

Note that I encountered the field modifier `` `transient``` for the first time.

private transient long originalTime;

General description

If transient is given, the corresponding field will not be serialized. If you try to serialize a class with the corresponding variable and add this modifier when `` `NotSerilizabaleException``` occurs, the exception will not occur for the time being.

What is serialization?

Besides serialization, it is also called serialization or serialization. Serializing with an object seems to make it possible to stream the information of an object and save it as a file or exchange it via a network. In short, it outputs a Java object as a byte string.

When can't I serialize?

In the first place, it is decided whether or not serialization is possible depending on the object. Attempting to serialize the class itself that has such an object would result in the exception mentioned above.

How to serialize

To serialize a class, implement `` `java.io.Serializable```. It is good to implement this interface with the proof that it can be serialized.

Personal summary

--Serialization is required when saving Java objects to a file or transmitting them over a network. --You need to implement `Serializable``` to serialize a particular class. --` `NotSerilizabaleException``` may occur when serializing classes. --Use `transient``` to exclude from serialization.

Recommended Posts

Regarding the transient modifier and serialization in Java
Java --Serialization and Deserialization
Write ABNF in Java and pass the email address
Java classes and instances to understand in the figure
Json serialization / deserialization in Java 1.4
JSON in Java and Jackson Part 1 Return JSON from the server
Correct the character code in Java and read from the URL
Think about the differences between functions and methods (in Java)
Access the network interface in Java
Guess the character code in Java
[Java version] The story of serialization
Encoding and Decoding example in Java
Specify the java location in eclipse.ini
Unzip the zip file in Java
StringBuffer and StringBuilder Class in Java
Parsing the COTOHA API in Java
Understanding equals and hashCode in Java
Hello world in Java and Gradle
Call the super method in Java
[Java] Get the dates of the past Monday and Sunday in order
Web application structure by Java and processing flow in the presentation layer
Get the result of POST in Java
Regarding String type equivalence comparison in Java
Difference between final and Immutable in Java
Specify the order in which configuration files and classes are loaded in Java
Java reference to understand in the figure
Java serialization
The story of forgetting to close a file in Java and failing
A note on the differences between interfaces and abstract classes in Java
JAVA learning history final modifier and static modifier
Try using the Stream API in Java
Call the Windows Notification API in Java
I tried the new era in Java
[Java] for Each and sorted in Lambda
[Java] Use cryptography in the standard library
Organized memo in the head (Java --Array)
Try calling the CORBA service in Java 11+
This and that of the implementation of date judgment within the period in Java
What is the main method in Java?
How to get the date in java
[Java 7] Divide the Java list and execute the process
Arrylist and linked list difference in java
Find the maximum and minimum of the five numbers you entered in Java
Program PDF headers and footers in Java
The story of writing Java in Emacs
Console input in Java (understanding the mechanism)
Understand the difference between int and Integer and BigInteger in java and float and double
Learn Flyweight patterns and ConcurrentHashMap in Java
[Java8] Search the directory and get the file
Java Direction in C ++ Design and Evolution
Java to C and C to Java in Android Studio
Reading and writing gzip files in Java
Difference between int and Integer in Java
Discrimination of Enums in Java 7 and above
How to create your own annotation in Java and get the value
I received the data of the journey (diary application) in Java and visualized it # 001
Java: Download the file and save it in the location selected in the dialog [Use HttpClient]
Impressions and doubts about using java for the first time in Android Studio
Parse the date and time string formatted by the C asctime function in Java
[Deep Learning from scratch] in Java 1. For the time being, differentiation and partial differentiation
Be careful with requests and responses when using the Serverless Framework in Java