SE450: Basics: Functions [23/63] |
What is a function?
file:Main.java [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
package basics.functions; public class Main { private Main() {} static public void main (final String[] args) { //stdlib.Trace.graphvizShowSteps (true); stdlib.Trace.run (); Fun.f(); Fun.g(2); } } class Fun { private Fun() {} static void f() { System.out.println("Fun.f()"); } static void g(final int x) { System.out.println("Fun.g(" + x + ")"); if (x>0) { final int y = x-1; Fun.g(y); } } }
Here is a visualization of the execution at four different point (time moving from left to right).