Derrik Antrium Derrik Antrium - 10 months ago 43
Java Question

How to identify signatures of a method in Java?

I believe that I am having trouble understanding how to give a signature of a method in Java. For example, if my code was:

public void addOn(Fraction other) {
number = other.denominator * number + other.numerator * denominator;
denominator = denominator * other.denominator;

and I had to give the signature of the method addOn();

Would the signature for this method simply be addOn(Fraction);?


In Java the method signature contains the name of the method and the data type of the arguments only and nothing else.

For eg in the method posted by you above:

public void addOn(Fraction other) {


the signature will be addOn(Fraction ).

This is one of the difference between C++ and java in C++ signature also contains return type but in java return type is not part of method signature. So in case of C++ method signature of above method will be void addOn(Fraction);