JavaIntermediate#serialization#keywords

What is the purpose of the transient keyword outside of serialization context — does it affect anything else?

transient only affects serialization, marking a field to be skipped when the object is serialized. It has no effect on normal execution, cloning, or reflection outside the serialization mechanism.

Example
class Session implements Serializable {
  transient String tempToken; // excluded from .ser file, null after deserialization
  String userId; // included
}

Related Questions

1
JavaIntermediate#interface#java8

What is the difference between an interface's default method and a static method?

Open
2
JavaAdvanced#streams#exceptions

What is the difference between checked exception wrapping in streams' lambdas — why can't you throw checked exceptions inside a lambda directly used in a stream?

Open
3
JavaAdvanced#collections#oop

What is the difference between the Comparable interface's compareTo() contract and a poorly implemented one?

Open