站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Eclipse 专题初学者的问题,程序能运行,警告提示不明白是什么?

初学者的问题,程序能运行,警告提示不明白是什么?

摘要: 初学者的问题,程序能运行,警告提示不明白是什么?


我现在用的eclipse3.1
以下是源代码,运行到是没问题,但就是在第四行(public class mJFrm extends JFrame)有个警告提示:The serializable class mFrm does not declare a static final serialVersionUID field of type long

不知道是什么原因,那位能帮我解释一下,谢谢了先!!!


//import java.lang.*;
import java.awt.*;
import javax.swing.*;
public class mJFrm extends JFrame
{
JLabel L1;
JTextField T1;
JButton B1;
JButton B2;
public mJFrm()
{
L1=new JLabel("输入您的代号:");
L1.setBounds(40,50,80,25);
this.getContentPane().add(L1);
T1 = new JTextField("在这里输入:");
T1.setBounds(125,50,90,25);
this.getContentPane().add(T1);
B1 = new JButton("Button1");
B2 = new JButton("Button2");
B1.setBounds(25,50,90,25);
B2.setBounds(125,50,90,25);
this.getContentPane().add(B1);
this.getContentPane().add(B2);

this.setBounds(0,0,300,250);
this.setBackground(Color.blue);
this.setTitle("This is my first JForm!");
this.setVisible(true);

}
public static void main(String[] para)
{
new mJFrm();

}

}



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:


ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;



这个值的用途见楼上,在这只是一个Warning,而非Error,你可以在编译器设置中忽略“Serializable class without serialVersionUID”这个选项。


楼上的说得对,可惜我来晚了



先谢谢楼上几位!!
晕,一楼帖的全是英文,我看不懂。
能不能给翻译一下?
再次感谢!


↑返回目录
前一篇: 请问:我将eclipse解压后,是否要配置什么?
后一篇: eclipse+tomcat+lomboz+mysql出现的问题