Home  >  Article  >  Java  >  What does a java source file consist of?

What does a java source file consist of?

青灯夜游
青灯夜游Original
2020-11-02 14:40:5313012browse

Java source file is composed of three parts: the first part is the class or external structure, such as "class Student{}"; the second part is the main() method, also called the entry of the program; the third part Part of the code is written in the main method.

What does a java source file consist of?

(Video tutorial recommendation: java video tutorial)

Java source file is composed of three parts,

The first part is a class or external structure:

What does a java source file consist of?

Example:

class Student{
}

The second part It is the main method, also called the entrance of the program

There are three points that everyone needs to pay attention to when learning:

What does a java source file consist of?

What does a java source file consist of?

The third part is writing the code

There are three points that everyone needs to pay attention to here:

1. The current code is written in the main method ;

2. You can write as many statements as you like, and the statements end with an English semicolon;

3. Suggestion: Write one statement per line.

The final output statement,

System.out.print(“大小写字母、数字、汉字以及特殊符号,但是输出后不换行”);
System.out.println(“输出内容同上,但是输出后换行”);

There is another point that needs to be learned, that is, comments, the following two points:

1. Function: explanation, in the program It is not executed in the program, mainly to increase the readability of the program

2. Category:

单行注释//
多行注释/* 注释内容 */
文档注释/** 注释内容 */

For more programming-related knowledge, please visit: Programming Teaching! !

The above is the detailed content of What does a java source file consist of?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn