静态最终长long serialVersionUID = 1L

关于我们教授给出的指导课程,我有一个简单的问题。我已经看过几次serialVersionUID,但是我没有什么用。

package module;

import java.io.IOException;

import java.io.PrintWriter;

import java.util.Scanner;

import javax.servlet.ServletException;

import javax.servlet.ServletOutputStream;

import javax.servlet.ServletResponse;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

/**

* @author JA

*/

public class Servlet_1 extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet{

static final long serialVersionUID = 1L;

public void doGet (HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("txt/html");

ServletOutputStream out = response.getOutputStream();

out.println("<html>");

out.println("<head><title>Hello Panget</title></head>");

out.println("<body>");

out.println("<h1>Hello Panget</h1>");

out.println("</body></html>");

}

protected void doPost (HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

// Write your program here, Panget.

}

}

什么是利用static final long serialVersionUID = 1L;程序中的?

回答:

serialVersionUID是一个通用版本标识符Serializable类。反序列化使用此数字来确保已加载的类与序列化的对象完全对应。如果未找到匹配项,则InvalidClassException抛出。

以上是 静态最终长long serialVersionUID = 1L 的全部内容, 来源链接: utcz.com/qa/408288.html

回到顶部