编译我的java小程序时有两个警告

时间:2012-10-08 01:53:40

标签: java applet appletviewer

package homework1;

import java.applet.Applet;
import java.awt.Graphics;

public class Homework1A extends Applet {

    public  void paint( Graphics g ){
        g.drawString("CIS 35A Student Learning Outcomes ",40,60);
    }
}

这是我得到的警告

The serializable class Homework1A does not declare a static final serialVersionUID field of type long 
Homework1A.java    /homework1/src/homework1    line 5    Java Problem

还有另外一个像这样的警告

Warning: Can't read AppletViewer properties file:

但是我运行了几次代码后它就消失了。

1 个答案:

答案 0 :(得分:2)

您的班级需要一个序列版UID,例如:private static final long serialVersionUID = 1L;

您可以将其用作参考:Serial IDs