Hi,
I came across this question in Dan's site under Operators.
class Color {}
class Red extends Color {}
class Blue extends Color {}
class A {
public static void main (String[] args) {
Color color1 = new Red(); Red color2 = new Red();
boolean b1 = color1 instanceof Color;
boolean b2 = color1 instanceof Blue;
boolean b3 = color2 instanceof Blue;
System.out.print(b1+","+b2+","+b3);
}}
Why should this code give a compile time error? I was under the impression that instanceof operator can only return a boolean value?Please clarify..
Thanks,
Malini