当前位置:网站首页>What if some fields don't want to be serialized?
What if some fields don't want to be serialized?
2022-08-02 05:44:00 【The cudgel meat Alexander Lord】
First, let's wire up what is serialization?What is deserialization?
If we need to persist Java objects, such as saving Java objects in files, or transmitting Java objects over the network, serialization is required in these scenarios.
- Serialization
The process of converting a data structure or object into a stream of binary bytes.
- Deserialization
The process of converting the binary byte stream generated during serialization into a data result or object.
In the Java language, what we serialize is the object (Object), that is, the instantiated class (class), but in the half-faced object language such as C++, the struct (structure) defines the dataStructural types, and classes correspond to object types.
So, the main purpose of serialization is to transfer objects over the network or to store objects in the file system, database, or memory.
What if some fields do not want to be serialized?
For variables that do not want to be serialized, use the transient keyword to modify them.
transient
keywords do
Prevent the serialization of variables in the instance that are modified with this keyword; when the object is deserialized, the value of the variable modified by transient will not be persisted and restored.
- A few more notes about transient:
- transient can only modify variables, not classes and methods.
- Transient modified variables, the variable value will be set to the default value of the type after deserialization.For example, if it is a modified int type, the result after deserialization is 0.
- Because the static variable does not belong to any object (Object), it will not be serialized whether it is modified with the transient keyword or not.
边栏推荐
猜你喜欢
ADSP21489仿真:Failed to set breakpoint: Can‘t set breakpoints in the current state: Running
Andrew Ng's Machine Learning Series Course Notes - Chapter 18: Application Example: Image Text Recognition (Application Example: Photo OCR)
CaDDN paper reading of monocular 3D target detection
OpenPCDet environment configuration of 3 d object detection and demo test
复制延迟案例(4)-一致前缀读
W25Q16 存储器(Flash)
PDF文件转换格式
LeetCode 23: 合并K个升序链表
Platts Analysis-MATLAB Toolbox Function
洛谷P2437蜜蜂路线
随机推荐
nr部分计算
什么是接触电流怎么测?
AFMG SysTune1.3.7使用图解
CaDDN paper reading of monocular 3D target detection
论文速读:Homography Loss for Monocular 3D Object Detection
Research Notes (8) Deep Learning and Its Application in WiFi Human Perception (Part 2)
其他重要协议(DNS,ICMP,NAT,交换机)
如何让固定点的监控设备在EasyCVR平台GIS电子地图上显示地理位置?
C程序调试过程常见的错误
Go 语言是如何实现切片扩容的?【slice】
3D object detection dataset
Deep Blue Academy - Fourteen Lectures of Visual SLAM - Chapter 4 Homework
Andrew Ng's Machine Learning Series Course Notes - Chapter 18: Application Example: Image Text Recognition (Application Example: Photo OCR)
batch_size of deep learning foundation
吴恩达机器学习系列课程笔记——第九章:神经网络的学习(Neural Networks: Learning)
安装部署 Kubernetes 仪表板(Dashboard)
日本痴汉打赏女主播1.5亿,结果。。。
Qt编写物联网管理平台49-设备模拟工具
分布式系统的一致性与共识(1)-综述
ScholarOne Manuscripts submits journal LaTeX file and cannot convert PDF successfully!