// 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) 
public class OptionFour {
    public static interface InterfaceTop {
        public String getValue(String... args); // note that it can be array or Map or custom interface/class
    }
    public static interface InterfaceSub1 extends InterfaceTop {
    }
    public static interface InterfaceSub2 extends InterfaceTop {
    }
    public static class ClassImpl1 implements InterfaceSub1 {
        @Override
        public String getValue(String... args) {
            if(args.length == 2) {
                return args[0] + args[1];
            } else {
                throw new UnsupportedOperationException("Invalid number of arguments");
            }
        }
    }
    public static class ClassImpl2 implements InterfaceSub2 {
        @Override
        public String getValue(String... args) {
            if(args.length == 1) {
                return args[0];
            } else {
                throw new UnsupportedOperationException("Invalid number of arguments");
            }
        }
    }
    public static void main(String[] args) {
        InterfaceTop i1 = new ClassImpl1();
        System.out.println(i1.getValue("ABC", "DEF"));
        InterfaceTop i2 = new ClassImpl2();
        System.out.println(i2.getValue("ABC", null));
    }
}
