Forums Register Login

Overloading doubt

+Pie Number of slices to send: Send
Why it is necessary(must) for arguments to differ?
+Pie Number of slices to send: Send
overloading example

public void methodA(int a) {}
public void methodA(int a, int b) {}

they need to have different signatures so it knows which to call.
if they where
public void methodA(int a) {}
public int methodA(int a) {}

how the compiler know which method you are after?

Hope that makes sense
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 606 times.
Similar Threads
core java programming doubts
overloading
Doubt in inheritance
doubt
Polymorphism doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:45:17.