Java Reference
In-Depth Information
3
Functions and Recursive Functions
3.1 Advantages of programming functions
The concept of functions in programming languages is quite different from the
usual mathematical notions, although it bears some similarity. Therefore it can
be confusing at first sight to make an explicit comparison. We rather prefer to
introduce the syntax of functions in Java, and show its two essential merits:
- Functions as subroutines for enhancing program modularity and code re-use,
- Functions defined recursively by themselves for novel computation paradigms.
Last but not least, by introducing functions, we will explain the difference
between local (say, usual block variables) and global memory variables (say,
static class variables). Java passes arguments in functions by value only. This
is a major fundamental difference with C++ that allows both by-value and
by-reference variable passing. Finally, describing recursion will help us explain
the function call stack of Java where local variables are temporarily allocated.
 
Search WWH ::




Custom Search