What is the purpose of transient keyword in Java?

1 answer

Answer

1103292

2026-04-21 15:45

+ Follow

A variable which is declared as transient will not be serialized. This means that when you use an ObjectOutputStream to store the current state of a class, anything labeled as transient will be skipped over.

A common use of this keyWord is to ensure that sensitive user information (usernames, passWords, etc.) is not accidentally saved to a file.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.