Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding methods with different variable names

I am having a methods like // Base Class

public void foo(long A, long b,long c)
 {
    //Implementation 1
 }

//Derived Class

public void foo(long AA,long b,long c)
  {
   //Implementation 2
  }

I would like to what is wrong with this design ? FYI: I am using Proxy pattern for my design

Thanks

like image 949
vasu1486 Avatar asked Sep 25 '26 22:09

vasu1486


1 Answers

The name of the parameters doesn't matter. Come run-time there is no way for java to tell which method you wanted to call at a given time. To overload methods the signatures have to be different so either there must be a different number of parameters or the parameters must be in a distinguishable order i.e. String, int and int, String.

like image 125
twain249 Avatar answered Sep 28 '26 22:09

twain249