question on serialization and readObject()

M

mitch gart

Suppose I'm doing my own serialization and am overriding readObject()
and writeObject(). Suppose the object I'm reading contains a field

private int x = -1;

If readObject() doesn't do an assignment to x, does x end up with the
value 0 or -1? Thanks,

- Mitch
 
D

David Zimmerman

zero. Upon reading objects from an ObjectStream, none of the
constructors run, including any initialization (which makes sense, since
the ObjectStream will probably just reset the initialization)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top