Forums Register Login

Help nedded !!!question all about serialization

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
Ew. You guys are ugly with a capital UG. Here, maybe this tiny ad can help:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 889 times.
Similar Threads
Serialization
How can I read all objects in a file with ObjectInputStream?
JQ+: I/O QUESTION
Question on primitive types and collections
Stuff about serializable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 02:10:46.