Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);?

like image 904
Derrik Antrium Avatar asked Aug 30 '25 17:08

Derrik Antrium


1 Answers

That really depends on the level of "accuracy" that you need.

When you informally talk to you coworker, then the "signature" would probably contain all information that a human being might find interesting:

  1. return type
  2. method name
  3. parameter types (including their ordering!)
  4. throws list
  5. ( annotations )

Whereas, when you come from a compiler-constructor or maybe JVM compiler point of view, the answer is different; in that case, only items 2, and 3 do matter; anything else is not part of the signature.

like image 63
GhostCat Avatar answered Sep 02 '25 07:09

GhostCat