When writing Java simple program code, the default file name is usually the same as the class name of the main class (the class where the main method is located), and the Java code naming rules are as follows, the class name must be named by Pascal, that is, the first letter of each word is capitalized. For example, HelloWorld F complies with General naming rules, but helloworld does not.
So what should we do when the file name is inconsistent with the main class name?
Now, the HelloJava. java file contains such code
Public class Java {
Public static void main (string [] args ){
System. out. println ("HelloJava! ");
}
}
The javac compilation command is the name of the Java program file to be operated. Generally, the extension suffix is *. java.
Java runs the explain command, which is the *. class file compiled by Java.
Therefore, when compiling, we can find that after executing the javac HelloJava. java command, we will find the Java. class file in the same directory. Then execute the java command to view the output result HelloJava.
This article is from the "FocusChaw" blog