Object a = new ArrayList();
System.out.print((a instanceof Collections)+","); //No error, why?
It doesn't matter that the type of the reference if Object - a is an ArrayList, and thus an instance of Collection. Not of Collection
s, though.
Animal a1= new Animal();
System.out.println("\n" + (a1 instanceof Collections)); //why error here
Yes, Animal extends Object, so "a1 instanceof Object" would be true, but it does not extend Collection.
[ April 05, 2007: Message edited by: Ulf Dittmer ]