Ganesh Gowtham wrote:
How the method mtd() is called autoboxing happends automatically ? , why not for this num(primitive) and num(wrapper) and confusion wont happend ?
Put yourself in the place of the compiler. In the case of the mtd() method, you only have one option, and the only way to get to Integer, when given an int is to autobox. In the case of num(), you have two options, and two perfect matches. Why bother looking into the option of boxing when you have a perfect match?
Or to answer your question... the compiler just doesn't try everything. It has an order, and have ways to resolve ambiguous issues too.
Henry