Home java Why do you need transient modifier?

Why do you need transient modifier?




What is the purpose of the modifier transient in Java?

Answer 1, Authority 100%

Serialization is a class instance conversion in a form suitable for its saving (for example, to a file, in database or for transmission over the network). Serialized objects can then be restored (deserialize).

Class properties marked by the transient modifier are not serialized.

Usually in such fields the intermediate state of the object is stored, which, for example, is easier to calculate than to serialize and then deserialize. Another example of such a field is a reference to an object instance that does not require serialization or cannot be serialized.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions