Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8323377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:42:31+00:00 2026-06-08T23:42:31+00:00

I have a serialized class that has variables ABC. I declare a serialVersionUID in

  • 0

I have a serialized class that has variables ABC. I declare a serialVersionUID in the class. I save an instance of the class into a text file using a vector. If I were to change the class (add variable D) I now have 2 different classes (the ABC that I am trying to read from the file, and the ABCD that is in the file). If I keep the serialVersionUID the same, will it just ommit D sense what I am trying to read only has ABC? example:

Class MyClass implements serializable
{
    serialVersionUID = 12345;
    int a = 0;
    int b = 0;
    int c = 0;  
}

Class implmentation
{
   MyClass me = new MyClass();
   me.a = 2;
   me.b = 4;
   me.c = 6;
} 

// save to txt file using objectOutputStream

// later change myClass to add int d = 0;

if I wanted to read the origional myClass object (me) from the text file, will it still be able to read it?

Sorry i don’t have a SSCCE but i want to verify before i start working on this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:42:34+00:00Added an answer on June 8, 2026 at 11:42 pm

    please take a look here http://denis-zhdanov.blogspot.com/2009/09/serialversionuid-update-policy-on-class.html

    deleting fields – If a field is deleted in a class, the stream written will not contain its value. When the stream is read by an earlier class, the value of the field will be set to the default value because no value is available in the stream. However, this default value may adversely impair the ability of the earlier version to fulfill its contract;

    adding fields – When the class being reconstituted has a field that does not occur in the stream, that field in the object will be initialized to the default value for its type. If class-specific initialization is needed, the class may provide a readObject method that can initialize the field to nondefault values;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data class that is serialized with the DataContractSerializer . The class
I have a class that serializes a set of objects (using XML serialization) that
I have a class which is serialized to and from an XML file when
I'll just get right into it. I have a class User that needs to
I have a class that contains multiple user objects and as such has an
I'm using gson 1.7 and i see that it has a serialized block in
If I have an instance of a class that I store in a session
I have a class that can be serialized. One of the properties is an
I have a class that extends Exception, and therefore has to be Serializable. The
I have a class that is inherited from List<T> and also has some properties,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.