Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.javarush.task.task20.task2011;
- import java.io.Externalizable;
- import java.io.IOException;
- import java.io.ObjectInput;
- import java.io.ObjectOutput;
- /*
- Externalizable для апартаментов
- */
- public class Solution
- {
- public static class Apartment implements Externalizable
- {
- private String address;
- private int year;
- /**
- * Mandatory public no-arg constructor.
- */
- public Apartment()
- {
- super ( );
- }
- public Apartment(String adr, int y)
- {
- address = adr;
- year = y;
- }
- /**
- * Prints out the fields. used for testing!
- */
- public String toString()
- {
- return ("Address: " + address + "\n" + "Year: " + year);
- }
- @Override
- public void writeExternal(ObjectOutput out) throws IOException
- {
- out.writeObject (address);
- out.writeInt (year);
- }
- @Override
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- address =(String)in.readObject ( );
- year = in.readInt ( );
- }
- }
- public static void main(String[] args)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement