-3

I'm analyzing a system that I support but I found

public class LanguageBacking implements Serializable {}

in a class that is responsible for setting the language of the same

I just want to understand When I use the Serializable interface and property

private static final long serialVersionUID = 8380243288947043866L;

when I help or how you get the number

I appreciate your help

  • Possible duplicate http://stackoverflow.com/questions/608647/what-is-serialization-in-java – sanbhat Jun 07 '13 at 17:39
  • http://stackoverflow.com/questions/447898/what-is-object-serialization – aglassman Jun 07 '13 at 17:41
  • 3
    -1 for not performing any research or reading the [documentation](http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html) – home Jun 07 '13 at 17:43
  • 2
    If you want to do serialization, please avoid this mechanism... It is non portable, except between Java, and full of pitfalls. – fge Jun 07 '13 at 17:51
  • @fge can you please provide alternatives... that helps me... :) – pinkpanther Jun 07 '13 at 17:52
  • possible duplicate of [What is a serialVersionUID and why should I use it?](http://stackoverflow.com/questions/285793/what-is-a-serialversionuid-and-why-should-i-use-it) – Brian Jun 07 '13 at 17:57
  • @pinkpanther JSON, XML, Google protobuf to name a few. – Aurand Jun 07 '13 at 18:07

2 Answers2

2

First of all you need to know what serialization is, according to java documentations serialization is where an object can be represented as a sequence of bytes that includes the object's data as well as information about the object's type and the types of data stored in the object.

After a serialized object has been written into a file, it can be read from the file and deserialized that is, the type information and bytes that represent the object and its data can be used to recreate the object in memory.

Most impressive is that the entire process is JVM independent, meaning an object can be serialized on one platform and deserialized on an entirely different platform.

If you are working with interprocess communication is very common to see Serializable objects, a good way to know if you need a serializable object is if you need to keep persistence of the object...

Regards!

Martin Cazares
  • 13,637
  • 10
  • 47
  • 54
0

If you want to be able to write objects to files and read back using ObjectOutputStream. You need to implement Serializable interface. This is the way java gives us by default.

This might help: Serializable Objects

pinkpanther
  • 4,770
  • 2
  • 38
  • 62