Java Serialization Example
Java Serialization Example
Sure! Here's a simple Java program that demonstrates serialization and deserialization of a
Student object with the attributes name , age , and id .
java
import java.io.*;
// Constructor
public Student(String name, int age, String id) {
this.name = name;
this.age = age;
this.id = id;
}
1/3
public class StudentSerializationDemo {
📝 How to Run:
1. Save the code in a file called StudentSerializationDemo.java
2. Compile it using:
nginx
2/3
javac StudentSerializationDemo.java
3. Run it:
nginx
java StudentSerializationDemo
You'll see console output showing the serialized and deserialized student object.
Want an example where you take input from the user too?
3/3