// 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.lang.reflect.Field;

public class ReflDemo {
    public static void dump(Object o) throws IllegalArgumentException, IllegalAccessException {
        for(Field f : o.getClass().getDeclaredFields()) {
            f.setAccessible(true);
            System.out.println(f.getType().getName() + " : " + f.get(o));
        }
    }
    public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {
        dump(new C1(123, "ABC"));
        dump(new C2(123.456, "XYZ"));
    }
}

class C1 {
    private int iv;                                 
    private String sv;
    public C1(int iv, String sv) {
        this.iv = iv;
        this.sv = sv;
    }
    public int getIv() {
        return iv;
    }
    public String getSv() {
        return sv;
    }
}

class C2 {
    private double xv;
    private String sv;
    public C2(double xv, String sv) {
        this.xv = xv;
        this.sv = sv;
    }
    public double getXv() {
        return xv;
    }
    public String getSv() {
        return sv;
    }
}
