I’m trying to extend LinkdList in Java through the following class definition:
public class Roster extends LinkedList<Teammate>{
}
but I get the following warning by doing so:
The serializable class Roster does not declare a static final serialVersionUID field of type long
What does that mean and how can I remove the warning?
The warning means you’re not doing what you “agree” to do when you extend that class. That class trusts that you’ll have a
static final serialVersionUID field of type longin your class if you extend it. That’s because itimplements Serializablewhich is an interface requiring this variable.To supress the warning add:
above the line where you declare the class (
public class Foo)To fix the warning declare the variable as follows:
And make sure the long you use is randomly generated.
Eclipse allows both of these options as a quick-fix by clicking on the yellow lightbulb next to the line number.