This week's book giveaway is in the OCAJP forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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: 9326
    
  19

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: 14489
    
  23

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 8 API documentation
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: 9326
    
  19

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
 
 
subject: Map IS-A Collection?