Here is the source program (source file) from the previous chapter. The purpose of this program is to type the characters Hello World! on the monitor.
class Hello { public static void main ( String[] args ) { System.out.println("Hello World!"); } }
The file must be named Hello.java to match the name of the class. On many computer systems, the upper and lower case characters of the file name are important. (So if the file is named hello.java with a small h it will not work). On all computers, upper and lower case inside the program are important. The first line
class Hello
Says that this source program will define a class called "Hello". A class is a section of a program. Small programs often consist of just one class. (A better definition of "class" will be given later.) When the program is compiled, the compiler will make a file of bytecodes called "Hello.class".
Some classes contain many lines. Everything that makes up a class will be placed between the first brace ( { ) and the matching last brace ( } ).
The name of the class (and therefore the name of the file) is up to you, as long as the name is made of alphabetical characters and digits with no spaces, the first character is alphabetical, and the name is not already in use. There will be more exact rules later on. The source file should always end with ".java" in lower case.