- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是一名新的java程序员。我试图在 Eclipse 中执行这个程序,但错误是
The serializable class LoveJava does not declare a static final serialVersionUID field of type long.
<小时/>
private static final long serialVersionUID = 1L;
为什么我必须声明这一行?
import acm.graphics.*;
import acm.program.*;
public class LoveJava extends GraphicsProgram {
private static final long serialVersionUID = 1L;
public void run(){
add(new GLabel("I love Java"),100,75);
}
}
最佳答案
欢迎来到java社区。
阅读specific API在问这里之前,这里是 API 的重要部分。
The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long:
关于java - 程序未执行-编译警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17024248/
我是一名优秀的程序员,十分优秀!