// simple generics tests ArrayList strings = new ArrayList(); strings.add("some string"); _checkEqual(strings.get(0), "some string"); // nested ArrayList>> test = new ArrayList(); // declaration class CustomList { private ArrayList items = new ArrayList(); void add(AnonymousType a) { items.add(a); } AnonymousType get(int index) { return items.get(index); } } CustomList c1 = new CustomList(); c1.add(1); c1.add(2); _checkEqual(c1.get(1), 2); // extends tests class A { } class B extends A { } // (?) there is no super in p5 class C { void method1(X x, CustomList list) {} public void method2(Y y) {} void method3(ArrayList a) {} } A a = A(); B b = B(); C > c = new C(); c.method1(b); c.method2(a); CustomList list = new CustomList(); list.add(a); c.method3(list); A a = new A(); B b = new B(); CustomList list = new CustomList(); list.add(a); ArrayList list2 = new ArrayList(); C > c = new C(); c.method1(b, list); c.method2(a); c.method3(list2); // anti-generics int i = 1, j = 2, q = 3; if(j<0) { i = 22; } _checkEqual(i, 22); if(0=false) { i = 44; } _checkEqual(i, 44); // next lines will fail, trade-off? // if(0>q) { i = 33; } _checkEqual(i, 33); // void func1(boolean a, boolean b) {} func1(0 0); // test array notation String[] strarr = {"a","b","c"}; HashMap hms1 = new HashMap(); hms1.put("a",strarr); _checkEqual(hms1.get("a"), strarr); HashMap hms2 = new HashMap(); hms2.put(strarr,"a"); _checkEqual(hms2.get(strarr),"a"); HashMap hms3 = new HashMap(); hms3.put(strarr,strarr); _checkEqual(hms3.get(strarr),strarr); String[][] strarr2 = {{"a","b","c"}}; HashMap hms4 = new HashMap(); hms4.put("a",strarr2); _checkEqual(hms4.get("a"), strarr2); HashMap hms5 = new HashMap(); hms5.put(strarr2,"a"); _checkEqual(hms5.get(strarr2),"a"); HashMap hms6 = new HashMap(); hms5.put(strarr2,strarr2); _checkEqual(hms5.get(strarr2),strarr2);