• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help nedded !!!question all about serialization  RSS feed

 
ananth chandran
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know how serialization is done internally
with primitives(int,long,float,boolean) and primitive objects
Long,Integer,Float..)

I have seen the forums that they use java.io.DataOutputStream
and they have writeInt,writeFloat methods for primitives types.But
still not clear does DataInputStream implements Serializable? How internally this works? How primitives are serialized when we make a
method call?

As far as primitive Objects(Long,Float..) I have seen they extend Number,
but then does Number implements serializable??

I saw Java docs but still not clear how this work internally??

I want to know if I can call a method with
method1(int a,float b)
nethod2(Integer a,Float b)and will that be serialized??

Does anyone ps help me understanding this concept?

Thanks in advance
ananth
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ananth,

It's clear from your questions that you're quite confused about what object serialization is. I'm not sure if I'm doing you a favour by pointing you to Sun's Object Serialization Guide or not. There is also some more condensed information in Sun's Java Tutorial.

What you need to understand is that it is only the data in an object that is serialized, i.e. the values held in the member fields[1]. Static data, local variables, methods, etc. are not serialized. Serialization is a means of packaging up an object's state so that it can be persisted (e.g. to disk) or transmitted as a stream.

[1] unless they're declared as transient.

Perhaps you'd benefit from writing a little program that serializes and persists a simple object and then taking a look at the output (which is binary).

Hope you find this useful.

Jules
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!