Public static void main (string [] ARGs) {} function understanding

Source: Internet
Author: User

The main function is generally written as follows:

Public static void main (string [] ARGs ){...}

The following describes the functions of these keywords:

(1) Public keyword. It is easy to understand that declaring the main function as public tells other classes to access this function.

(2) The static keyword tells the compiler that the main function is a static function. That is to say, the code in the main function is stored in the static storage area, that is, this code already exists after the class is defined. If the main () method does not use the static modifier, the compilation will not go wrong, but if you try to execute this program, an error will be reported, prompting that the main () method does not exist. Because the class containing main () is not instantiated (that is, the object without this class), its main () method will not be saved. The static modifier indicates that the method is static and can be used without instance.

(3) The Void keyword indicates that the return value of main () is of no type.

** (4) string [] args.

Public static void main (string [] ARGs) {} function understanding

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.