序列化

    1. public class User implements Serializable {
    2. //这个序列化id,使得这个类在网络中传输也可以让接收方的JVM识别为同一个类
    3. private static final long serialVersionUID = 1L;
    4. private String name;
    5. private String age;
    6. public User(String name, String age) {
    7. this.name = name;
    8. this.age = age;
    9. }
    10. public String getName() {
    11. return name;
    12. }
    13. public void setName(String name) {
    14. this.name = name;
    15. }
    16. public String getAge() {
    17. return age;
    18. }
    19. public void setAge(String age) {
    20. this.age = age;
    21. }
    22. @Override
    23. public String toString() {
    24. return "User{" +
    25. "name='" + name + '\'' +
    26. ", age='" + age + '\'' +
    27. '}';
    28. }
    29. }