序列化问题
import java.io.*;
public class DataObject implements Serializable
{
private static int i=0;
private String word=" ";
public void setWord(String word)
{
this.word=word;
}
public void setI(int i)
{
this.i=i;
}
public String toString()
{
return "word:"+word+";i="+i;
}
public static void main(String[] args) throws ClassNotFoundException,FileNotFoundException,IOException
{
DataObject object=new DataObject();
object.setWord("123");
object.setI(2);
System.out.println(object);
ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream("lql.out"));
out.writeObject(object);
ObjectInputStream in=new ObjectInputStream(new FileInputStream("lql.out"));
DataObject object2=(DataObject)in.readObject();
System.out.println(object2);
}
}
运动后:word=123;i=2;
word=123;i=2;
这如何解释呢?
请帮忙一下,谢谢!
相关推荐
springboot mybatis里localdatetime序列化问题的解决
主要介绍了springboot mybatis里localdatetime序列化问题,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
redis使用过程中由于序列化工具引起的问题
NULL 博文链接:https://yuhuiblog695685688425687986842568269.iteye.com/blog/2423496
Spark中序列化问题
第一种情况 假设我们数据需要与规则数据进行匹配,在Class中定义规则,此时不对它进行序列化。 Class Rules { val rulesMap = Map(hadoop -> 1, spark -> 2) val hostname = InetAddress.getLocalHost.getHostName println(hostname + @@@@@@@@@@@@@@@@) } 如果我们在程序中使用map操作使规则和数据进行匹配。 val r = lines.map(word => { val rules = new Rules //
java 中序列化NotSerializableException问题解决办法
主要介绍了java 中序列化NotSerializableException问题解决办法的相关资料,这里对序列化问题进行描述说明,并提供解决办法,希望能帮助到大家,需要的朋友可以参考下
golang中json反序列化可能遇到的问题
主要给大家介绍了关于golang中json反序列化可能遇到的问题的解决方法,文中通过示例代码介绍的非常详细,对大家学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。


Java SE

