1

Possible Duplicate:
Why should I bother about serialVersionUID?

I've been learning how to use Java's graphics classes. When I made a simple FlowLayout, I got a warning in Eclipse IDE telling me I should add a serialversionUID before my Layout contructor class.

It now looks like:

public class ShowFlowLayout extends JFrame{
/**
 * 
 */
private static final long serialVersionUID = 1L;

public ShowFlowLayout() {...

What is a serialVersionUID? Is it important to have?

Community
  • 1
  • 1
Zolani13
  • 225
  • 2
  • 6
  • That's part of the contract for classes that implement Serializable, of which JFrame is one. But it's a warning, not an error, so feel free to ignore it if you wish or to use a trivial serial version id or an annotation to have the compiler ignore it,... – Hovercraft Full Of Eels Apr 08 '12 at 02:47

1 Answers1

1

Eclipse asks you to add serialVersionUID to all serializable classes. Since JFrame implements Serializable, your class does too, hence it should have a serialVersionUID. Note that it is not required, only strongly suggested.

Community
  • 1
  • 1
Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523