This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes regarding serializatiotion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "regarding serializatiotion" Watch "regarding serializatiotion" New topic
Author

regarding serializatiotion

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

Saral Saxena wrote:Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!

Not always do you want to serialize the object, and not all objects are going to be serialized.


Mohamed Sanaulla | My Blog
Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Mohamed Sanaulla wrote:
Saral Saxena wrote:Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!

Not always do you want to serialize the object, and not all objects are going to be serialized.


Hi ,

could you please come up with any technical example that will make understandings more clear..!!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

I dont know the real technical reason, but I can think of it. I dont think its a good idea to unnecessarily extend/implement classes/interfaces (even though they might be just Marker interface). If they are not marker interfaces then you would end up polluting the class with unnecessary implementations, extensions.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Saral Saxena wrote:
Mohamed Sanaulla wrote:
Saral Saxena wrote:Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!

Not always do you want to serialize the object, and not all objects are going to be serialized.


Hi ,

could you please come up with any technical example that will make understandings more clear..!!


What's not clear? We only want some classes to be serializable, not all. If Object implements Serialzable, then everything would implement it, and we don't want that.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

An interface cannot be "unimplemented". If the Object class implemented the Serializable interface, all Java objects would inevitably implement it as well, and subsequently there would not be any need for that interface at all. The way it is now, a class designer can choose whether his class should or should not implement that interface and can therefore decide whether the class will be serializable or not.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

Saral Saxena wrote:Hi Folks,

Could you please advise me the technical reason that why the Object class was not made to implement the serializable interface..!


And if in case they did, you already know from this thread, what wrong it can do.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: regarding serializatiotion