Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method overloading or not?

scenario: There are two methods in same class with same name with different arguments and different access modifiers. E.g.:

public void m1(int a){}
private void m1(String b){}

is it overloading or not?

like image 679
Amol Amrutkar Avatar asked Jul 19 '26 23:07

Amol Amrutkar


1 Answers

Yes - in a word, yes. To quote Oracle's Java tutorial:

This means that methods within a class can have the same name if they have different parameter lists

In other words - the access modifiers are inconsequential to this discussion.

like image 140
Mureinik Avatar answered Jul 22 '26 15:07

Mureinik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!