it's the Foo[] object, not Object, instanceof Foo, Bar, Face, get result false.

I think this is not a correct result, because you can't pass the compile.

Manfred Klug

Ranch Hand

Posts: 377

posted 10 years ago

Originally posted by Joseph Zhou: it's the Foo[] object, not Object, instanceof Foo, Bar, Face, get result false.

I think this is not a correct result, because you can't pass the compile.

I think you confuse two things.

The instanceof check, which will be correct even if you use a parent type for the reference variable, and the compile error which will always occur if there is no relation between the classes. For example: The compilation will fail, since the compiler knows that it is impossible that foo IS A Bar.

Joseph Zhou

Ranch Hand

Posts: 129

posted 10 years ago

Repeat my question: Is the line in the table at the page correct?

Manfred Klug

Ranch Hand

Posts: 377

posted 10 years ago

Originally posted by Joseph Zhou: Repeat my question: Is the line in the table at the page correct?

Yes, since nobody forces you to use a reference variable of type Foo[]. For the test you need only an object of type Foo[].

Joseph Zhou

Ranch Hand

Posts: 129

posted 10 years ago

Sorry Manfred, I think we are forced, otherwise there is "Object" in the table, not Foo[].