java - Can changes in the order of the method parameters be called method overloading? -


please note order of parameters changed in below example. question - can call below example of method overloading?

public void show(string s, int a){     system.out.println("test.show(string, int)"); } public void show(int s, string a){     system.out.println("test.show(int, string)"); } 

yes, that's absolutely method overloading.

from section 8.4.9 of jls:

if 2 methods of class (whether both declared in same class, or both inherited class, or 1 declared , 1 inherited) have same name signatures not override-equivalent, method name said overloaded.

"override-equivalent" described in section 8.4.2:

two methods have same signature if have same name , argument types.

[ ... details on "same argument types ... ]

the signature of method m1 subsignature of signature of method m2 if either:

  • m2 has same signature m1, or

  • the signature of m1 same erasure (ยง4.6) of signature of m2.

two method signatures m1 , m2 override-equivalent iff either m1 subsignature of m2 or m2 subsignature of m1.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -