Two Laptop Bag
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes dan new collections 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 "dan new collections" Watch "dan new collections" New topic

dan new collections

tony kanvas
Ranch Hand

Joined: Oct 26, 2002
Posts: 97

dan said The first method call, m(null,null), calls method m with two null literals that have type null. Both null literals are promoted to type B because B is more specific than type A
but if you see A its same as B why compiler take B
John Paverd
Ranch Hand

Joined: Nov 17, 2002
Posts: 115
Imagine the following class hierarchy:
class Animal {}
class Mammal extends Animal {}
class Horse extends Mammal {}
This makes it a bit easier to see that a sub class is more specific than a super class. Any horse is an animal, but not every animal is a horse.
JLS section has more information about choosing the most specific method:
The informal intuition is that one method declaration is more specific than another if any invocation handled by the first method could be passed on to the other one without a compile-time type error.

SCJP 1.4
Abu Yoosuf
Ranch Hand

Joined: Nov 14, 2002
Posts: 33
Originally posted by tony kanvas:

I agree. Here's the link:
subject: dan new collections
It's not a secret anymore!