File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

instance of operator

 
cybel sheriden
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

instance of test can be don on obj ref variable ,to see if they are of a class or interface type.

i didn't understand the last three test(Foo[], Foo[1]) in table 3-2 (page 159 of K&B)
 
Mike Gershman
Ranch Hand
Posts: 1272
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One key fact is that the element type, Foo, is different from the array type, Foo[].
If we say "Foo[] f;", then f is of type Foo[] but f is not of type Foo. f[1] is of type Foo.

The other key fact is that every array type is a subclass of Object[] and Object[] is a subclass of Object, so every array type is a subclass of Object.
[ February 22, 2005: Message edited by: Mike Gershman ]
 
Animesh Shrivastava
Ranch Hand
Posts: 298
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Mike,
The other key fact is that every array type is a subclass of Object[] and Object[] is a subclass of Object, so every array type is a subclass of Object.


Mike, i guess this statement should be true only for array of reference types. I mean any integer array(int[]) is not a subclass of Object[].
Please let me know if i am wrong

Thanks
 
Mike Gershman
Ranch Hand
Posts: 1272
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike, i guess this statement should be true only for array of reference types. I mean any integer array(int[]) is not a subclass of Object[].
Please let me know if i am wrong

You are correct. I forgot about arrays of primitives. They are subclasses of Object but not Object[].
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic