Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

instance of

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface face{}
class bar implements face{}
class foo extends bar{}

foo[] instanceof foo,bar,face is false
foo[1] instanceof foo,bar,face,Object is true

K&B book page no 286
can any one explain what is happening here...
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i guess foo[1] is initialized and an instance but foo[] may not be one...
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy cowboys,

there is an erratum on that page.
An instance of and array of any type is not an instance of that type, only an instance of an array of that type.
- Ehem. To explain:

Due to the table, the outcommented line would print "false" if commented in.
But it would not print "false", it would not compile.
Because a Foo[] is an Array, it is not in the hierarchy line of Foo, so it cannot compile.


So the fifth line of the table:



This is not yet listed on the errata page.


Thanks,
Bu.
 
srinivas sridaragaddi
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Burkhard,


Thanks for letting us know about the errata...

i was about to mess up every thing as it was not found on errata..
thank you
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic