Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Map IS-A Collection?

 
Harry Henriques
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain why the instanceof operator doesn't return false?




output True?
 
Ankit Garg
Sheriff
Posts: 9518
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you create a custom class named Collection??
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Himanshu Kansal
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ankit Garg
Sheriff
Posts: 9518
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alread solved here...
 
shukla raghav
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Map is not a consider a because it does not implement the Collection interface
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic