Signatures

Figure 236. Type signatures Slide presentation Create comment in forum

A method's return and arguments type list. Examples:

Method Type signature
Return type Argument type list
void print() {...} void (void)
int add (int a, int b) {...} int (int, int)
int maximum (int a, int b){...} int (int, int)
void print (int a, float b){...} void (int, float)
void display (float a, int b){...} void (float, int)

Figure 237. Defining type signatures Slide presentation Create comment in forum
  • Return type, e.g. void

  • Number of arguments, e.g. 2.

  • Type of arguments among with their respective order, e.g. (int, double) differing from (double, int).


Figure 238. A method signature Slide presentation Create comment in forum

A method's name and arguments type list:

Method Method name Method signature
void print() {...} print (void)
int add (int a, int b) {...} add (int, int)
int maximum (int a, int b){...} maximum (int, int)
void print (int a, float b){...} print (int, float)
void display (float a, int b){...} display (float, int)