先说下为什么我们要将对象存储起来。使用缓存机制不仅可以为用户节省流量,同时还可以给用户带来好的用户体验。
class MyBean implements Serializable {
private static final long serialVersionUID = 1L;
private boolean myBoolean;
private String myString;
private Vector<String> myVector;
public MyBean() {
}
public boolean isMyBoolean() {
return myBoolean;
}
public void setMyBoolean(boolean myBoolean) {
this.myBoolean = myBoolean;
}
public String getMyString() {
return myString;
}
public void setMyString(String myString) {
this.myString = myString;
}
public Vector<String> getMyVector() {
return myVector;
}
public void setMyVector(Vector<String> myVector) {
this.myVector = myVector;
}
}
存储的对象一定要继承Serializable接口序列化 为什么要序列化对象: