当前位置:网站首页>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.
transientkeywords 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.
边栏推荐
- MySQL存储函数详解
- Deep blue college - handwritten VIO operations - the first chapter
- Deep Learning Basics Overfitting, Underfitting Problems, and Regularization
- 力扣 215. 数组中的第K个最大元素
- 今天突然下雨
- 面试官:大量请求 Redis 不存在的数据,从而打倒数据库,有什么方案?
- Camtasia 2022简体中文版屏幕录像和视频编辑软件
- STM32 OLED显示屏
- How to save a section of pages in a PDF as a new PDF file
- SCI写作攻略——附带常见英语写作句式
猜你喜欢

Deep blue college - handwritten VIO operations - the first chapter

CaDDN paper reading of monocular 3D target detection

数学建模学习(76):多目标线性规划模型(理想法、线性加权法、最大最小法),模型敏感性分析

Qt常见问题

CaDDN code debugging

W25Q16 存储器(Flash)

The most authoritative information query steps for SCI journals!

安装部署 Kubernetes 仪表板(Dashboard)
Deep Blue Academy - Handwritten VIO Homework - Chapter 2

Reinforcement Learning (Chapter 16 of the Watermelon Book) Mind Map
随机推荐
热爱责任担当
高等数学(第七版)同济大学 总习题三(后10题) 个人解答
斐波那契数列
Deep Blue Academy - Fourteen Lectures of Visual SLAM - Chapter 4 Homework
AFMG SysTune1.3.7使用图解
爬虫_爬取wasde月度供需平衡表(实例)
无主复制系统(1)-节点故障时写DB
Arduino框架下ESP32重启原因串口信息输出示例
lvm扩容(实战无废话)
PyQt5_pyqtgraph鼠标在折线图上画直线
不会多线程还想进 BAT?精选 19 道多线程面试题,有答案边看边学
如何让固定点的监控设备在EasyCVR平台GIS电子地图上显示地理位置?
Sentinel熔断之非控制台方式总结
“数字化重构系统,搞定 CEO 是第一步”
ADSP21489数据手册表摘要
Unreal回放系统剖析(上)
MySQL存储函数详解
互动投影墙深受展览展示喜爱的原因分析
使用 Fastai 构建食物图像分类器
批量--10---根据set数拆分文件