• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

instance of

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
On top of spaghetti all covered in cheese, there was this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic