Home > Java > JavaBase > body text

There are several types of java entry functions

angryTom
Release: 2019-11-16 16:04:20
Original
4580 people have browsed it

There are several types of java entry functions

There are several types of java entry functions

There is only one java entry function, and it must start with main Name it and modify it with public static.

Entry (Entry of Program): refers to the starting point of program operation.

Only the main method can be used as the entry point of the program.

Main method structure:

public static void main(String[] args) {
方法体
}
Copy after login

Observing this method, you can see:

This is a public static modified method, so it is a Static method. The return value is of void type, that is, there is no return value. The method name is main. The parameter is a String array.

When running a program, the main method is usually used as the starting point, and the first statement in the main method is used as the first statement of the program. Since the main method is a static method, this method can be executed in any class.

The form of the main method is fixed. The following writing methods cannot be used as the entry point of the program:

public static void mian()                                                      With String[] parameters

public static int main(String[] args) //The return value must be void

public void main(String[] args) //Must be static

php Chinese website, a large number of free Java introductory tutorials, welcome to learn online!

The above is the detailed content of There are several types of java entry functions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template