Java Reference
In-Depth Information
When you save a Java source code file, the Java compiler will expect the file
name to match exactly the class name assigned at the beginning of your program
in line 10 of Figure 2-19 on page 64. Java is case-sensitive , which means that
the Java compiler considers uppercase and lowercase as two different characters.
If you use a class name beginning with an uppercase letter, you also must begin
the file name with an uppercase letter. Conventionally, Java programmers use
uppercase letters, as opposed to underlines, to distinguish words in the class
names, such as MyAddressProgram or OctoberPayroll.
All code entered after the class header is considered to be the body of the
class and must be enclosed in braces { } . The opening brace is displayed in line
11 in Figure 2-19; the closing brace will display later in the code. Perform the
following step to enter the class header and its opening brace.
To Code the Class Header
1. With the insertion point in line 10 in the coding window, enter the class
header and opening brace in lines 10 and 11, as shown in Figure 2-19
on page 64.
The class header is displayed (Figure 2-20). The keywords, public and class,
are displayed in blue, and the opening brace is displayed in red. When you
press the ENTER key after a brace, TextPad automatically indents the next
line.
keywords
class header
opening
brace
insertion point
automatically
indented
FIGURE 2-20
In Java, using a pair of opening and closing braces to enclose a portion of
code indicates that they form a single, logical unit in the program, such as a
class. It does not matter if you place the opening brace on the same line as the
access modifier and class name or on the next line. When writing code, it is good
programming practice to be consistent in the placement of the opening brace.
 
Search WWH ::




Custom Search