java - Which method is looked first by Compiler , Static or instance method when ClassName.staticMethod() is used? -


i want proper understanding why below compilation error? per understanding if use test.xyz() compiler static method not instance method why below compilation fail?

class test {     public static void main(string arg[]) {         test.xyz(10);     // compilation fail     }         public void xyz(int i) {     }     public static void xyz(integer i) {     }     } 

every 1 please suggest why compilation fail rather other suggestions , how use , i know basic thing autoboxing etc .

this question asked me which method looked first compiler , static or instance method when classname.method() used? in question of people go in wrong direction due mistake in question moved question new question.

you wrong in assumption: compiler first specific candidate methods signature (method name+parameters), without boxing. means selected method non static one.

then in second step compiler see call method static 1 syntax <class>.<method>().

it's why error.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -