Why does Eclipse warn me to add a serialVersionUID?

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?


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.

链接地址: http://www.djcxy.com/p/23848.html

上一篇: 如何处理java.io.InvalidClassException?

下一篇: 为什么Eclipse警告我添加一个serialVersionUID?