I will try to answer as accurately as possible, but without knowing the language the answer may not be true, although I am confident that this goes for almost every case.
appendFooter(s);
appendFooter(StringBuffer report)
s
would be an argument and give the parameter name to report
.
It is possible to say that the parameter, in the report
case, is output as much as it is input.
Input parameter
void metodo(int x) {
print x;
}
This is a case where the parameter is input. Anything that is sent to this method goes in one direction, the object enters the method.
Input and output parameter
void metodo(array x) {
x[0] = 1;
}
In this case the object is a type by reference, so it sends the method only a form of pointer that gives access to the object. Any change to the object will be reflected in the argument. Then you can transfer a value to the argument via the
It goes in two directions. It enters a value in the method and a value of that method can exit.
In the example the element 0 of array will have a value of 1 even when the method terminates. It is a way to return a value by the parameter itself.
If the argument is not a variable, this return can not be used for anything afterwards, since there will be output, but it will be discarded.
It is possible in some languages to prevent output in types by reference, something like this:
void metodo(const array x) {
x[0] = 1;
}
In this case any change in x
will not be reflected in the argument, so there is no way out.
Output Parameter
void metodo(out int x) {
x = 1;
}
Some languages have purely output parameters. In this way the argument must be a variable that is required to receive the value that the method sends to it. It is not possible to send a value to the method, so if the variable has a value, it is not sent as input parameter. It has only one direction, the exit.
In this example x
will have a value of 1 at the end of the method, and who called the method will get this value, something like this:
var int a;
metodo(a);
print a; //imprimirá 1
This is a useful resource for having multiple returns in the method, since it is normal for it to only return a value. Some languages have the capability to return multiple values, which does not have a unique output parameter.
Conclusion
I assume that type StringBuffer
is a type by reference, so report
is an input and output parameter.