• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

instanceof

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
given:-

Question:- what is Foo[]...I mean the '[]' part ?? and what is Foo[1] ??
is it an array ?...afaik, arrays were something like:-
bla [] x = new bla[3];

TIA

(attempt at formatting)
[ November 13, 2004: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where did this notation come from? Talk about confusing...

My guess is that Foo[] is meant to be an array of Foo objects. That would then lead me to believe that Foo[1] would be a single Foo object from that array.
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I understand what you are trying to say

The first column is implying what to put in the first operand of the instanceof

For example:

(1st operand) instance of (Foo, Foo[], etc)

So for your first row, If you do Foo[] instanceof (Foo or Bar or Face) the result is false

Because Foo[] is not an instance of any of those objects
 
Netty poestel
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's the table 3-2 from the 3rd chapter of the K & B book.
 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note in the table that Object is not a choice for the Foo[] truth table because that would return true.

I suppose the point of the table is to emphasize the types of objects (note small letters) in Java and that an array is not only a type of Object (note caps) but also a different type of object (note small letters) from the Objects (note caps) it holds.
reply
    Bookmark Topic Watch Topic
  • New Topic