① First Program HelloWorld
1 Packager Myjava; // equivalent to a directory 2 class 3{4public staticvoid 5 {6 System.out.println ("Hello world!" ); 7 }8 }
② Note:
1. The file name must be the same as the public decorated class name, with. Java as the suffix of the file, but if the defined class is not public decorated, the file name can be different from the class name .
2. There can be multiple classes in a. java file, but there is only one class that is public-decorated. So in a. java file, there are several class classes, and there can be only one class of public
3.java source code files after compiling, a class name corresponds to the generation of a. class file . Whether he is a public modifier or a class that does not have any modifiers.
4. A Java application should contain a main () method, and the signature is fixed, and he is the entry method for the main program. can be defined in any class. is not necessarily in the public-decorated class.
The first Java program