Filename:HelloWorld.javapublic class HelloWorld {public static int data = 100; public static void Main (string[] args) {System.out.println ("Hello Java world!"); SYSTEM.OUT.PRINTLN (data); }}
d:\> Javac helloworld.javad:\> java helloworldhello java world!
Create a new text in the Windows D drive with a text editor, enter the code above, and then open the command line with (Win + R-cmd). The "Javac" command is a Java compiler that compiles a "*.java" file into a "*.class" byte file, which can then be run on any machine that has a Java virtual machine installed. The Java command is a Java interpreter that can be loaded directly into the virtual machine to interpret the execution of the "*.class" file.
This is the Java's smallest program, Java's first feature is abstract, the program is composed of many classes, the class is the basic unit of the program, each class to implement each function, multiple functions together is a program. The program in the previous example has only one class, the class "HelloWorld" as defined by the "class" keyword.
A class consists of two members, one is a property used to store data, one is a method to manipulate the data, and the members of the class must be decorated with "static". As in the example class "HelloWorld", there is a property member "data" with a method member "main".
The "Main ()" method is a special method, the entry of the program, is called by the virtual machine, the "main ()" method is called, the program begins execution, "main ()" finished executing the program. Because it is the entry of the program, so the reputation must follow the specification, otherwise, the virtual machine cannot find the "main" function, cannot find the entrance program can not be executed. "Public" is publicly accessible, that is, it can be called outside of this class, "static" means that it is a member of the class, "void" means that the return value of the method is null, that is, there is no return value, "main" is the method name, "()" method name after the parentheses inside the argument list, In this example, there is only one parameter, "String" of type args. Inside the "{}" brace is the method body.
"System" is a generic class defined in the class library, encapsulates the system resources, "out" attribute members encapsulate the standard output device, is part of the system resources, "println" is an output device output method. "System.out.println (" Hello ")" is the output method that calls the system output device to print "Hello".
A brief analysis of the starter program of JAVA programming