if (o instanceof Fruit)
Fruit a (Fruit) a
I am using a java/javac version 1.6. Any idea why this is not working for my compiler ? I assume it should work because all classes inherit from Object. I thought it was referring to the wrong Object class, so I changed the method to public boolean add(java.lang.Object o), which seems to work.