‫Welcome back.
‫In this video, we'll learn about method overloading with method overloading.
‫Multiple methods can have the same name with different parameters.
‫For example, in this method, add numbers we passed int x and int y and the return statement will return
‫x plus y, the summation of x and y in form of an int.
‫The same.
‫Here I'll create another method called add numbers and the returning type.
‫This time will be a double add numbers.
‫Double.
‫Z and double W Here the return will be Z plus W, So Z plus W is a double and the return type is double.
‫Here.
‫Add numbers and enter it.
‫Steady will not generate any errors because we specified the same name of the method.
‫But here he the Android studio will understand that this is a method overloading.
‫Now I want from you to focus with me with this very important note.
‫You can see when we call add numbers and we pass arguments ten and 20 which are integers.
‫The method add numbers that return end will be called and add numbers will be in yellow because in yellow
‫means that it is used.
‫You can hover your mouse cursor over any method or any keyword in Android studio and you will get some
‫hints.
‫You can see add numbers in grey it's never used.
‫So when passing ten and 20 integers, Android studio will go and use the corresponding method according
‫to the passed integers.
‫If I pass a double so 10.7 and 20.3, you can see that add numbers that accepts integers will not be
‫called and then add numbers method that accepts double and return double it will be called.
‫And this is according to the type of parameters, the method or the corresponding method will be called
‫if we run the program now you can see that the value is 31.0 and the returning type is double.
‫So this method is being called and this method is not being called.
‫When we pass double values as arguments.
‫This is called in Java method overloading.