-2

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

mjs
  • 20,001
  • 28
  • 109
  • 183

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
  • 24,336
  • 15
  • 57
  • 93