aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Collections doubt?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Collections doubt??" Watch "Collections doubt??" New topic
Author

Collections doubt??

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9389
    
    2

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


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Sanjeev Singh
Ranch Hand

Joined: Nov 01, 2006
Posts: 381
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 ]

~Sanjeev Singh<br />SCJP 1.5
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9389
    
    2

Sanjeev, thanks for the help.
Bob CHOI
Ranch Hand

Joined: Nov 10, 2006
Posts: 127
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 ]

Hard work rewards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collections doubt??