Vince Tan wrote:Question 1 - why will that be a compilation error? I tried putting "d instance Cat" into a if condition and it returns false as expected but not a compilation error, am i missing something?
Vince Tan wrote:Question 2 - what's the difference between Foo[] and Foo[1], what is the book trying to imply?
Question 3 - when I run instanceof Foo[] f = new Foo[1] against Bar, I get a compilation error (incompatible conditional operand types), so why is the table in the book stated that it will return false ?
Vince Tan wrote:My code is actually very simple
Vince Tan wrote:Btw, could you clarify what it means by different hierarchies, does it have to be on a different package entirely?
Vince Tan wrote:Would be good if you could give me a couple of examples on when it will be a compilation error instead of returning a false. For example, based on my understanding at runtime when using instanceof on a Cat to a Dog I expect it to return false instead of a compiler error, unless the whole point of instanceof is actually for generics?
Roel De Nijs wrote:And you are correct: the table contains an error. This line Foo [] instanceof [Foo, Bar, Face] -> false should be Foo [] instanceof [Foo, Bar, Face] -> compiler error. Well spotted.
Paddy O Riley wrote:Foo [] does not appear anywhere. Are we supposed to assume that Foo [] is an array of Foo objects ?
Paddy O Riley wrote:Should this definition not be supplied in the pre-cursor code or is there something more fundamental that I am missing ?
What's wrong? Where are you going? Stop! Read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|