• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collections doubt??

 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

The question below is from Dan Chisholm,



I thought it should have given me a compile time error at Line 3 in the code above, since c1 which is an instance of Map is in a different hierarchy. I'm confused??
 
Sanjeev Singh
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.print(c1 instanceof Collection);//Line 3

You are checking the instance (c1 which is of type Object at runtime it is TreeMap)within a same hierarchy..so its OK.
[ December 18, 2006: Message edited by: Sanjeev Kumar Singh ]
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sanjeev, thanks for the help.
 
Bob CHOI
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are checking the instance (c1 which is of type Object at runtime it is TreeMap)within a same hierarchy..so its OK.


According JAVA API



Map interface and implementers aren't inherited from Collection, are they?

[ December 18, 2006: Message edited by: Bob CHOI ]
[ December 18, 2006: Message edited by: Bob CHOI ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic