Skip to content
欢迎扫码关注公众号

Java 泛型类型的序列化

代码结构如下:

java
public class ValueResult<T>{
    private T data;
}

返回结果为 ValueResult<Integer> 时序列化出错:

class java.lang.Object must be java.io.Serializable


猜测应该是 T 默认会被解析为 Object 型,导致在编译时出错。因为给泛型加个了可序列化的约束就解决了该问题。

java
public class ValueResult<T extends Serializable>

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.