Return type

In computer programming, the return type (or result type) defines and constrains the data type of the value returned from a subroutine or method.[1] In many programming languages (especially statically-typed programming languages such as C, C++, Java) the return type must be explicitly specified when declaring a function.

In the Java example:

public void setShuma(int n1, int n2) {
    Shuma = n1 + n2
}

public int getShuma() {
    return Shuma;
}

the return type is int. The program can therefore rely on the method returning a value of type int. Various mechanisms are used for the case where a subroutine does not return any value, e.g., a return type of void is used in some programming languages:

public void returnNothing()
  1. ^ Kernighan, Brian W.; Ritchie, Dennis M. (1988). The C Programming Language (2nd ed.). Prentice Hall. ISBN 0-13-110362-8.