aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Map IS-A Collection? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Map IS-A Collection?" Watch "Map IS-A Collection?" New topic
Author

Map IS-A Collection?

Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206
Can you explain why the instanceof operator doesn't return false?




output True?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Did you create a custom class named Collection??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13868
    
  10

I tried this:

It prints false.

Part of the code in line 1 of your example is cut off. What's supposed to be there?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
Harry Henriques wrote:Can you explain why the instanceof operator doesn't return false?




output True?


Just for confirmation you can try fully qualifying Collection as java.util.Collection


Experience and talent are independent of age
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Alread solved here...
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
Map is not a consider a because it does not implement the Collection interface
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Map IS-A Collection?
 
Similar Threads
instanceof operator
Aren't Collection and AbstractMap peers? what's the common subclass?
Maps
Collection
instanceof question