class List { Object[] data; boolean[] present; List(int size){ data = new Object[size]; present = new boolean[size]; for(int i = 0; i < size; i++){ data[i] = 0; present[i] = false; } } void add(Object x){ int i = 0; while(present[i] & i < present.length){ i++; } if(i == present.length) return; data[i] = x; present[i] = true; } boolean contains(Object x){ for(int i = 0; i < data.length; i++){ if(data[i] == x & present[i]) return true; } return false; } void remove(Object x){ for(int i = 0; i < data.length; i++){ if(data[i].equals(x) & present[i]){ present[i] = false; data[i] = 0; } } } int length(){ int l = 0; for(int i = 0; i < present.length; i++){ if(present[i]) l++; } return l; } void printAll(){ for(int i = 0; i < data.length; i++){ if(present[i]) System.out.println(data[i].toString()); } } public static void main(String args[]){ String s1 = "Hello"; String s2 = "Hello"; System.out.println(s1.equals(s2)); Animal a1 = new Animal("Mickey"); Animal a2 = new Animal("Mickey"); System.out.println(a1.equals(a2)); List l = new List(100); Object o1 = new Plant("Tree2"); l.add(new Animal("Mickey")); l.add(new Plant("Tree1")); l.add(new Animal("Mini")); l.add(o1); l.add(new Animal("Donald")); l.add(new Rectangle(20, 10)); System.out.println(l.length()); l.printAll(); l.remove(o1); System.out.println(l.length()); l.printAll(); } }