Java Reference
In-Depth Information
We know that at this point, the computer stops executing
main
and turns its atten-
tion to the
drawTriangle
method. This step is analogous to picking up the piece of
paper with
drawTriangle
written on it and placing it over the piece of paper with
main
on it:
public static void main(String[] args) {
drawTriangle();
public static void drawTriangle() {
System.out.println(" *");
System.out.println(" ***");
System.out.println("*****");
System.out.println();
}
drawTwoTriangles();
}
Now we execute each of the statements in
drawTriangle
from first to last, then
go back to
main
, removing the
drawTriangle
sheet. When we go back to
main
we
will have finished the call on
drawTriangle
, so the next step is the call on
drawTwoTriangles
:
public static void main(String[] args) {
drawTriangle();
drawTwoTriangles();
}
So we grab the piece of paper with
drawTwoTriangles
on it and place it over the
paper with
main
on it:
public static void main(String[] args) {
drawTriangle();
public static void drawTwoTriangles() {
drawTriangle();
drawTriangle();
}
drawTwoTriangles();
}
The first thing to do here is the first call on
drawTriangle:
public static void main(String[] args) {
drawTriangle();
public static void drawTwoTriangles() {
drawTriangle();
drawTriangle();
}
drawTwoTriangles();
}
Search WWH ::
Custom Search