vijay umar wrote:
here i have the doubt regarding the relation between Foo[] and FOo,bar,Face which gives an false on instanceof operation between them and Foo[1] and foo,bar,face,Object instanceof relation gives true result how is this possible !! what is the difference between foo[] and foo[1];
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
Alexander Danilou wrote:IMHO trying to compile Foo[] instanceof Foo (or Bar, of Face) should give compile time error, something like inconvertible types, am I wrong???
but where do we declare an object like foo[1]....
i thought it is an array element... isnt it!
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
vijay umar wrote:That means array object of a class is different from the actual object of a class!! isnt it
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
Bob Wheeler wrote:
vijay umar wrote:That means array object of a class is different from the actual object of a class!! isnt it
Yes. They even don't share the same inheritance tree. So if you compare them with then instanceof operator, you get a compiler error.
cheers
Bob
Nigel
If a cast of the RelationalExpression (the left operand of instanceof) to the ReferenceType (the right operand of instanceof) would be rejected as a compile-time error, then the instanceof relational expression likewise produces a compile-time error.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Nigel
Nigel Shrin wrote:a guess we're saying - that's the spec', that's how it is -- as opposed to why
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Nigel
Regards
Salil Verma
Don't get me started about those stupid light bulbs. |