serialVersionUID缺少时,Eclipse会发出警告.
可序列化类Foo不声明long类型的静态最终serialVersionUID字段
serialVersionUID它是什么以及为什么重要?请显示缺失serialVersionUID会导致问题的示例.
我在标题中给出了警告信息.我想了解并删除它.我在这个问题上找到了一些答案,但由于技术术语过载,我不理解这些答案.用简单的词语解释这个问题有可能吗?
PS我知道OOP是什么.我知道什么是对象,类,方法,字段和实例化.
PPS如果有人需要我的代码,它在这里:
import java.awt.*;
import javax.swing.*;
public class HelloWorldSwing extends JFrame {
JTextArea m_resultArea = new JTextArea(6, 30);
//====================================================== constructor
public HelloWorldSwing() {
//... Set initial text, scrolling, and border.
m_resultArea.setText("Enter more text to see scrollbars");
JScrollPane scrollingArea = new JScrollPane(m_resultArea);
scrollingArea.setBorder(BorderFactory.createEmptyBorder(10,5,10,5));
// Get the content pane, set layout, add to center
Container content = this.getContentPane();
content.setLayout(new BorderLayout());
content.add(scrollingArea, BorderLayout.CENTER);
this.pack();
}
public static void createAndViewJFrame() {
JFrame win = new HelloWorldSwing();
win.setTitle("TextAreaDemo");
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setVisible(true);
}
//============================================================= main
public …Run Code Online (Sandbox Code Playgroud)