public static void Main (String arg[]) explains in detail

Source: Internet
Author: User
Public static void Main (String arg[]) The statement defines the main method. The main method is the entrance to the program execution, and all Java programs must have a main () method, and must be defined as above. A class that does not have a Main method can be compiled, but cannot execute. Because it does not have the main method as the starting point for execution. Public is the access modifier and can be accessed from anywhere if the class member is in addition to it. Static means that you can call the main method without creating an instance of the class, because, in general, the class cannot be accessed without instantiation. However, if there is a keyword static before the method, it can be accessed directly through the class name even if the class instance is not created. Because the JVM will call the main () method before the other process, Therefore, the main () method should not rely on an instance of any class to be created and must be declared as static. The keyword void tells the compiler that when this method is executed, it does not return any values. The variables contained within the parentheses () of the main () method are the arguments passed to the method, even if the main method does not require arguments, and the method name must still have parentheses. String arg[] is a parameter passed to the main () method. arg[] is an array of string types. The arguments passed in the command line are stored in this array. A pair of curly braces for the main () method is a method block. The statement to be executed from the main method needs to be specified in this block.

public static void Main (String arg[]) detailed explanation (RPM)

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.