• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Object Serialization

 
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read it ,
If while serialization ,an onject references to same object twice,only 1 reference is saved .Ie if object graph repeats the object.
there was an example ,
class kernel
{
Cat c1=new Cat();
Cat c2=new Cat();}

here ,i both c1-c2 arenot there different objects on Heap,Only reference type is same .
Please help me clearing my doubt
THank you
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you think of some code to test this?
 
Lucky J Verma
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No marc,
I think we cannot test this,thats why i am in doubt.It was from head First,Book by Kathy Sierra.

I am sorry if it was some unreasonable query.
Thank you
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question isn't unreasonable. Marc was trying to get you to find a way to test whether the same object is written once or many times.

The code you showed uses different objects, so they are definitely both written; that doesn't help answer the question. You need code where you have more than reference to the same object - let's say 1000 references. If you had serialized representation of a single object or a 1000 objects, would you be able to tell them apart?
 
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
You need code where you have more than reference to the same object - let's say 1000 references. If you had serialized representation of a single object or a 1000 objects, would you be able to tell them apart?

There is no need for so much references. The test is much simpler than you think.
 
Manfred Klug
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lucky J Verma:
I think we cannot test this

try it, and you will learn something. If you don't find a way to test it, ask again and I will give you the program. If you are not sure if your test is correct, post your code and we will help you.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic