Java simple program design-Relationship between file names and class names

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.