<java Basic >java Main class structure <2>

Source: Internet
Author: User
Tags modifier

PS: When you learn these Java programs, please install a dedicated IDE (integrated development environment), and learn to use, because these things to see the video is much faster than the word learning =w=.


The Java language is an object-oriented programming language, the basic components of Java programs are classes, and the class body includes attributes and methods two parts. Each program must contain a main () method, and the class containing the main () method is called the main class.


Java main class structure (//,/* These two symbols represent comments):

Package com; The statement for this line represents the package that declares the class, and the package is the keyword

public class test{

static String S1 = "Hello"; The statement on this line represents the creation of a (global variable)

/**

* the following main () is the main method of the program, the method from the "{" sign, to the "}" number end.

* Public, static, void are the main () method's permission modifier, the statics modifier, and the return value modifier.

* string[] args is an array of string types and is a parameter to the main () method.

* The main () method is where the program starts executing.

*/

public static void Main (string[] args) {

String s2 = "Java"; The statement on this line represents the creation of a (local variable)

System.out.println (S1);

SYSTEM.OUT.PRINTLN (S2);

}

}


Program Run Result:

How are you doing

Java


PS: This is a main class structure, a Java application is composed of a number of classes, I know if you are beginning to look at Java, now you may be very confused, in what are modifiers, local variables, global variables, arrays, parameters, why these things in Java is so, do not worry, Later, will be specifically to talk about these things, if you are interested, you can Baidu to see, for the moment you need to know is that this is a Java program just fine.



<java Base >java main class structure <2>

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.