// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.*;

public class BooleanSize {
    private static int size(Object o) throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(1000);
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(o);
        return baos.toByteArray().length;
    }
    public static void main(String[] args) throws Exception {
        System.out.println(size(new BooleanArray(0)));
        System.out.println(size(new BooleanArray(10000)));
        System.out.println(size(new BooleanArray(20000)));
        System.out.println(size(new B0()));
        System.out.println(size(new B1()));
        System.out.println(size(new B2()));
        System.out.println(size(new B3()));
        System.out.println(size(new I0()));
        System.out.println(size(new I1()));
        System.out.println(size(new I2()));
        System.out.println(size(new I3()));
    }
}

class BooleanArray implements Serializable {
    private boolean[] b;
    public BooleanArray(int n) {
        b = new boolean[n];
    }
}

class B0 implements Serializable {
}

class B1 implements Serializable {
    private boolean b1 = true;
}

class B2 implements Serializable {
    private boolean b1 = true;
    private boolean b2 = true;
}

class B3 implements Serializable {
    private boolean b1 = true;
    private boolean b2 = true;
    private boolean b3 = true;
}

class I0 implements Serializable {
}

class I1 implements Serializable {
    private int i1 = 1;
}

class I2 implements Serializable {
    private int i1 = 1;
    private int i2 = 1;
}

class I3 implements Serializable {
    private int i1 = 1;
    private int i2 = 1;
    private int i3 = 1;
}
