Java Programming/Keywords/transient - Wikibooks, Open Books For ...

Jump to content
  • Book
  • Discussion
English
  • Read
  • Edit
  • Edit source
  • View history
Tools Tools move to sidebar hide Actions
  • Read
  • Edit
  • Edit source
  • View history
General
  • What links here
  • Related changes
  • Upload file
  • Page information
  • Cite this page
  • Get shortened URL
  • Download QR code
Sister projects
  • Wikipedia
  • Wikiversity
  • Wiktionary
  • Wikiquote
  • Wikisource
  • Wikinews
  • Wikivoyage
  • Commons
  • Wikidata
  • MediaWiki
  • Meta-Wiki
Print/export
  • Create a collection
  • Download as PDF
  • Printable version
In other projects Appearance move to sidebar hide From Wikibooks, open books for an open world < Java Programming | Keywords

transient is a Java keyword which marks a member variable not to be serialized when it is persisted to streams of bytes. When an object is transferred through the network, the object needs to be 'serialized'. Serialization converts the object state to serial bytes. Those bytes are sent over the network and the object is recreated from those bytes. Member variables marked by the java transient keyword are not transferred; they are lost intentionally.

Syntax:

private transient <member-variable>; or transient private <member-variable>;

For example:

Computer code publicclass FooimplementsSerializable { privateStringsaveMe; privatetransientStringdontSaveMe; privatetransientStringpassword; //... }

See also:

  • Java language specification reference: jls
  • Serializable Interface. Serializable
Retrieved from "https://en.wikibooks.org/w/index.php?title=Java_Programming/Keywords/transient&oldid=3583767" Category:
  • Book:Java Programming/Keywords
Hidden categories:
  • Pages using deprecated enclose attributes
  • Pages with deep filing
Search Search Java Programming/Keywords/transient Add languages Add topic

Tag » What Is Transient In Java