0% found this document useful (0 votes)
5 views1 page

How Static Variable Serializable in Java - Google Search

In Java, static variables are not serialized because they belong to the class itself rather than to any specific instance of the class. The only exception is the special static variable serialVersionUID, which is used during the serialization and deserialization process. This means that static variables do not retain their values when an object is serialized and later deserialized.

Uploaded by

sristi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

How Static Variable Serializable in Java - Google Search

In Java, static variables are not serialized because they belong to the class itself rather than to any specific instance of the class. The only exception is the special static variable serialVersionUID, which is used during the serialization and deserialization process. This means that static variables do not retain their values when an object is serialized and later deserialized.

Uploaded by

sristi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

how static variable serializable in java

All Videos Images Shopping Web News Books

मराठी मध्ये शोधा java मध्ये स्टॅ िटक व्हेिरएबल सीिर…

AI Overview

Listen

No, static variables are not serialized in Java,


except for the special static variable
serialVersionUID :
Explanation
Serializing an object converts its state into a byte
stream that can be reverted back into a copy of the
object. Static variables are not serialized because
they belong to the class itself, not a specific instance
Showthat
of the class. This means morethere is only one copy of
the variable in memory, regardless of how many
instances of the class are created.

मराठी मध्ये In English

In Java, serialization is a concept using


which we can write the state of an object
into a byte stream so that we can transfer it
over the network (using technologies like
JPA and RMI). But, static variables belong to
class therefore, you cannot serialize static
variables in Java. 29 Jun 2020
https://www.tutorialspoint.com › c...

Can we serialize static variables in Java? -


TutorialsPoint
About featured snippets Feedback

People also ask

How to make a variable Serializable in Java?

How are static variables initialized in Java?

Why are static members not pa! of the


serialization process?

How do static variables work in Java?

Feedback

Stack Overflow
https://stackoverflow.com › are-sta...

java - Are static variables serialized in


Serialization process
I'm stumbled upon understanding java serialization. I have read
in many documents and books that static and transient
variables cannot be serialized in ...

• Instance Variables: These serialVersionUID is a spec


variables are serialized, so during static variable used by the
deserialization we will ... More serialization and deserializ
... More
Top answer · 73 votes 55 votes

Java static serialization rules?


21 Jun 2011

Serialization of static inner class - java


9 Apr 2012

How to save static variable when I serialize - java


26 Sept 2017

More results from stackove!low.com

Medium · Kiran Kumar


50+ likes · 2 years ago

Can we serialize static variables in java? | by


Kiran Kumar - Medium
serialVersionUID is a special static variable used by the
serialization and deserialization process, to verify that a local
class is compatible ...

Quora
https://www.quora.com › Why-are...

Why are static variables not serialized?


Why are static variables not serialized?

Static variables are not serialized In Java, Serialization is the


because they belong to the class mechanism of writing the s
rather than to any particular ... of an object into a byte str
More ... More
4 votes

People also search for

Can we serialize static variables in Java

Why static variables are not serialized in


Java

Serialization in Java

Transient and static variable in serialization

Volatile keyword in Java

Transient keyword in Java

TutorialsPoint
https://www.tutorialspoint.com › a...

Are the values of static variables stored


when an object is serialized in Java?
2 Aug 2019 — The values of static variables will not be
preserved during the de-serialization process. In-fact static
variables are also not serialized but since these ...

Videos
24 - Java Serialization with static
!elds - Code Demo
YouTube · Rishi Srivastava
12:15
3 Dec 2022

Static fields are never part of still addition and deceleration


process so let's try to understand this better in IntelliJ by…

are the values of static variables


stored when an object is…
2:41
serialized ? Software Solutions
YouTube · Durga
1 Sept 2016

More videos

javabeginnerstutorial.com
https://javabeginnerstutorial.com › ...

Transient vs Static variable java - Java


Beginners Tutorial
29 Dec 2013 — A static variable cannot be serialized. While de-
serializing a value can be available for Static variables if the
same is provided while ...

Coderanch
https://coderanch.com › java › Role...

Role of static variables in


serialization/deserialization
9 Nov 2012 — Q: What about static variables? Are they
serialized? A: Nope. Remember. static means "one per class"
not "one per object".

Serialization of static variables (I/O and Streams forum…


at Coderanch)
24 Jul 2005

Serialization of static variables - Coderanch


24 Jul 2011

confusion regarding serialization with static and…


transient variable - Coderanch
25 Aug 2006

Using static variables in Serialization - Coderanch


26 May 2012

More results from coderanch.com

Stack Overflow
https://stackoverflow.com › are-sta...

java - Are static variables serialized in


Serialization process
I'm stumbled upon understanding java serialization. I have read
in many documents and books that static and transient
variables cannot be serialized in ...

• Instance Variables: These serialVersionUID is a spec


variables are serialized, so during static variable used by the
deserialization we will ... More serialization and deserializ
... More
Top answer · 73 votes 55 votes

Coderanch
https://coderanch.com › java-io › java

Static variable ge#ing serialized


In the following code, the static variable should not be
serialized, but I see it as serialized. Please let me know where
did I get it wrong.

People also search for

Transient variable in Java

Can we serialize Singleton class in java

serialVersionUID in Java

Synchronization and serialization in Java

Advantages of serialization in Java

Serialization in Java W3Schools

More search results

India

Nagpur, Maharashtra - Based on your past activity

Update location

Dark theme: on Help Feedback

Privacy Terms

You might also like