// 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.util.*;

public class GenericGenerics {
    public static void main(String[] args) {
        //compiler ikke//List<Comparable> lst1 = new ArrayList<Integer>();
        List<Integer> lst1 = new ArrayList<Integer>();
        lst1.add(77);
        lst1.add(117);
        //compiler ikke//List<Comparable> lst2 = new ArrayList<String>();
        List<String> lst2 = new ArrayList<String>();
        lst2.add("77");
        lst2.add("117");
        List<Comparable> lst3 = new ArrayList<Comparable>();
        lst3.add(77);
        lst3.add("117");
        test1(lst1);
        //compiler ikke//test2(lst1);
        test1(lst2);
        //compiler ikke//test2(lst2);
        //runtime error//test1(lst3);
        //runtime error//test2(lst3);
    }
    public static void test1(List<? extends Comparable> lst) {
        System.out.println(lst.get(0).compareTo(lst.get(1)));
    }
    public static void test2(List<Comparable> lst) {
        System.out.println(lst.get(0).compareTo(lst.get(1)));
    }
}
