Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Overloading doubt  RSS feed

 
ketan khairnar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why it is necessary(must) for arguments to differ?
 
Kris Reid
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!