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>