File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 JavaScript Promises Essentials this week in the JavaScript 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: 9311
    
  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: 14337
    
  22

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: 9311
    
  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?