Advertisement
EBobkunov

Serializable Employee

Mar 11th, 2023
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | Source Code | 0 0
  1. import java.io.*;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         try(ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("person.dat")))
  7.         {
  8.             Employee e = null;
  9.             oos.writeObject(e);
  10.         }
  11.         catch(Exception ex){
  12.  
  13.             System.out.println(ex.getMessage());
  14.         }
  15.  
  16.     }
  17.  
  18.     public class Employee implements Serializable {
  19.         public String name;
  20.         public String address;
  21.         public transient int SSN;
  22.         public int number;
  23.         public final int BIRTH_YEAR = 2000;
  24.         public transient String password = "MyPassword2000";
  25.         public String nickname;
  26.         public static int dayOff;
  27.         public void mailCheck() {
  28.             System.out.println("Mailing a check to " + name + " " + address);
  29.         }
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement