Game Development Reference
In-Depth Information
Let's start with comments, as this topic is the easiest to grasp, and you have already
seen comments in your InvinciBagel game bootstrap Java code, in Chapter 2 . There are
two ways to add comments into Java code: single-line, also referred to as “ in-line,
comments, which are placed after a line of Java code logic, and multiple--line, or
block ,” comments, which are placed before (or after) a line of Java code or a block of
Java code (a Java code structure).
The single-line comment is usually utilized to add a comment regarding what that
line of Java logic, which I like to call a Java programming “ statement ,” is doing, that
is, what that line of Java code is there to accomplish within your overall code structure.
Single-line comments in Java start with the double forward slash sequence. For in-
stance, if you wanted to comment one of the import statements in the InvinciBagel
bootstrap code that you created in Chapter 2 , you would add double forward slashes
after the line of code. This is what your Java code would look like once it has been
commented (see also Figure 3-1 , bottom right):
import javafx.stage.Stage // This line of code imports
the Stage class from JavaFX.stage package
Figure 3-1 . Multiline comments (first five lines of code, at the top) and single-line comments (last three lines of code,
at the bottom)
Next, let's take a look at multiline comments , which are shown at the top of Figure
3-1 , above the package statement (which you will be learning about in the next sec-
tion). As you can see, these Java block comments are done differently, using a single
 
 
Search WWH ::




Custom Search