Product Method Overloading

后端 未结 2 1594
花落未央
花落未央 2021-01-23 23:01

so I was working on this problem on CodeHS, then I was stuck for so long so decided to ask here.

The exercise is to overload the product method to allow for multiplying

2条回答
  •  太阳男子
    2021-01-23 23:57

    Method overloading means you can create methods with same method name by changing those methods parameters (parameter count,parameter type and parameter Patterns). Combination of method name and parameters also called as method signature

    Following is an example for method overloading.

    public void int myMethod(){} 
    
    public void int myMethod(int a){} 
    
    public void String myMethod(String a){} 
    
    public void double myMethod(int a , String a){} 
    
    public void int myMethod(String a,int a){} 
    

    Note that you can't overload methods by changing return type

提交回复
热议问题