Write your first Java application

Step :
The write Java code to a file with the extension .java.
Java files compiled by the javac command.
By the java command to run the class file

Package com.uncleyong; 
 
public  class the HelloWorld {
     // main method 
    public  static  void main (String [] args) {
         // print string in the console 
        System.out.println ( "the Hello World!" ); 
    } 
}

Description:

package: keywords, expressed package

com.uncleyong: package name, dot represents in windows \

public: java modifier, public

class: keyword indicating that the class

HelloWorld: class name

static: java modifier, static

void: represents the return type

main: Java application execution entry is main () method. It has a fixed writing format: public static void main (String [] args) {...}, if not the main method is thrown at run time the following exception

String [] args: method's parameter list, String is a class name, represents the string, args variable name can be changed

System: class name, the class system

out: property class system, a system output stream

println: system output stream Method

"Hello World!": String, wrap in double quotes

Strict Java language is case sensitive

Java method consists of a statement, each statement ends with a semicolon 

A Java source file can have up to a public class. Any number of other classes, if the source file contains a public class that must be named class name.

 

Note

Note: The text for explanation of the program to improve the readability of the code.
Annotation type in Java:
  single-line comments, format: // comment text
  multiline comment format: / * comment text * /
  Documentation Comments (java-specific) format: with  / *  start to  * / end, document annotation allows you embed in your program information about the program, with this comment javadoc tool you can use software to generate information, and output to an HTML file
comments is a programmer must have good programming practice.

Their thoughts by commenting sorted out first, then the code to reflect

For single-line and multi-line comments, annotated text will not be JVM (java virtual machine) interpreted

Multi-line comments are not allowed inside nested multiple-line comments. 

 

Statement, article reproduced from the full-stack test notes https://www.cnblogs.com/UncleYong/p/9729156.html  Thanks for sharing the power of God.

Guess you like

Origin www.cnblogs.com/majunBK/p/11513094.html