wood burning stoves 2.0*
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action 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: 9293
    
  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: 14114
    
  16

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