Common basic java helloworld explanation



public class HelloWorld{  //表示顶一个公开的类,起名HelloWorld
    
    /*
        public表示公开的
        static表示静态的
        void表示空
        main表示方法名 
        String[] args 是一个main方法的形式参数列表
    */

    public static void main(String[] args) {  
        
        System.out.println("Hello World");
    }
    
}

    public means open
    class means define a class
     HelloWorld means a class name


    public static void main (String [] args) // Define a public static main method, program entry

     The java statement is terminated with a semicolon;

    All strings in java need to be enclosed in double quotes

 

 

The difference between public class and class

* Multiple classes can be defined in a java source file

* A java source file does not necessarily have public class, public class is not necessary

* A class will be defined to generate a xxx.class bytecode file

* If a public class is defined in a java source file, there can only be one public class, and the class name must be the same as the java source file name.

Published 248 original articles · Like 602 · Visit 1.08 million +

Guess you like

Origin blog.csdn.net/qq_32963841/article/details/104749092