Game Development Reference
In-Depth Information
tional statements, lambda expressions, and interfaces, all of which you will be learning
about over the course of this topic.
As illustrated in Figure 3-2 , Java code blocks delimited using curly braces can be
nested (contained) inside of each other, allowing far more complex Java code con-
structs. The first (outermost) code block using curly braces is the InvinciBagel class,
with other constructs then nested as follows: the start() method, the .setOnAction()
method, and the handle() method. You will be examining what all this code does as
this chapter progresses. What I want you to visualize now (with the help of the red
squares in Figure 3-2 ) is how the curly braces are allowing your methods (and class) to
define their own code blocks (structures), each of which is a part of a larger Java struc-
ture, with the largest Java structure being the InvinciBagel.java class itself. Note how
each opening curly brace has a matching closing curly brace. Note as well the indent-
ing of the code, such that the innermost Java code structures are indented the farthest to
the right. Each block of code is indented by an additional four characters or spaces.
As you can see, the class is not indented (0), the start() method is 4 spaces in, the
.setOnAction() method is 8 spaces in, and the handle() method is 12 spaces in.
NetBeans 8.0 will indent each of your Java code structures for you! Also notice that
NetBeans 8.0 draws very fine (gray) indentation guide lines in the IDE so that you can
line up your code structures visually, if you prefer.
Figure 3-2 . Nested Java code blocks for the InvinciBagel class, start method, setOnAction method, and handle meth-
od
 
 
Search WWH ::




Custom Search