-2

Java serialVersionUID must be static? Can it be an instance variable set by a sub class through constructor?

mjs
  • 21,431
  • 31
  • 118
  • 200

1 Answers1

1

From the Serializable docs.

A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long.

So it must be static.

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95