Site icon Codeforcoding

The transient keyword in Java language

The transient keyword in Java language

In this tutorial, we will discuss The transient keyword in Java language

In the Java programming language, the transient keyword is used with instance variable to avoid them from serialization process.

if you define any data member as transient, it will not be serialized.

Transient is an access modifier denoted the JVM to skip the particular variable or object when serializing an object /instance of the class

The transient keyword cannot be used static keyword in Java because the static variable cannot be changed.

The transient keyword can only use an instance variable

 

Declaration

Syntax

private transient <member-variable>;    or

transient private  <member-variable>;

 

Example

transient int age;

transient String  name;

 

There are other Java language keywords that are similar to this keyword

There are other Java language keywords that are similar to this keyword

abstract keyword in Java

boolean Keyword in Java

break keyword in Java

Byte keyword in Java 

case keyword in Java 

catch keyword in Java 

char keyword in Java 

class keyword in Java 

continue keyword in Java 

default keyword in Java 

do keyword in Java

double keyword in Java

else keyword in Java

enum keyword in Java

extends keyword in Java

final keyword in Java

finally keyword in Java

float keyword in Java

for keyword in Java

if keyword in Java

static keyword in Java

super keyword in Java

 

Suggested for you

Usage of this statement in the Java language

Keywords in Java language

Keywords in C language

Keywords in Python language

 

The const keyword in Java programming language
The instanceof operator in Java programming language
Exit mobile version