Tuesday, March 11, 2014

java method signature

Two of the components of a method declaration comprise the method signature—the method's name and the parameter types.

public double calculateAnswer(double wingSpan, int numberOfEngines, 
double length, double grossTons) {
//do the calculation here

The signature of the method declared above is:
calculateAnswer(double, int, double, double)

public is modifier
double is the return value type
throw XyzException is not part of signature.

JVM identify method by its signature, the difference on modifer, return type or exception thrown won’t affect JVM to locate the method.

No comments:

Post a Comment