next up previous
Next: Evaluation of a method Up: Unit 02 Previous: Method signature and method

Parameters and results of a method

The parameters of a method represent the arguments that the calling block passes to the method, and that are necessary to realize the operation the method should perform.

Example: the method println(String s) can be called on the object System.out through the statement System.out.println("ciao!"). The parameter represented by the string "ciao" is used inside the method as the string to print on the output channel (the monitor), denoted by System.out.

If the method has to return a result (return type is different from void), such a result is computed by the method and returned to the calling block.

Example: consider the method String concat(String s). If we call such a method on the string "JA" and pass it as parameter the string "VA", it computes and returns the string "JAVA".


next up previous
Next: Evaluation of a method Up: Unit 02 Previous: Method signature and method