• Post Reply Bookmark Topic Watch Topic
  • New Topic

doublt regarding serialization  RSS feed

 
Pankaj Mittal
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when ever we want to serialize object we can implement serializable interface and if we want we can override writeobject and readobject methods..

but my que is, if we want to implement an interface, we have to implement all of its methods, there is no choice...but here we have choice whether to implement them or not...it seems to be like I'm forgetting sth...
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Serializable is what's called a marker interface, that is, it doesn't actually contain any methods. The readObject() and writeObject() methods are hooks that let you have some control over the serialization process, but they aren't part of the interface.
 
Pankaj Mittal
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok....didn't know about market interfaces...

Thanks a lot !!
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome! And it's marker, not market. That was probably just a typo, but I'm just making sure.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pankaj Mittal wrote:Ok....didn't know about market interfaces...

Its Marker interface and JavaDocs explains that java.io.Serializable.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!