first java program

package mypack; // Equivalent to a directory public class HelloWorld{ public static void
main(String[] args) { System.out.println("Hello World!"); } }
notes :

1. The file name must be the same as public The modified class names are consistent , with .java As file suffix , If the defined class is not public Of , The file name and class name can be different .

2. One .java There can be more than one in the file class, But there was only one public Modified class . After the source code file is compiled , One class generates one .class file .

4. One Java An application should contain a main() method , And its signature is fixed , It is the entry method for the application , Can be defined in any class , Not necessarily public Modified class .

compile :javac -d .

Classes containing packages , It is best to use the above format when compiling ,-d It refers to the generation of the class according to the package structure ,“.” It is generated in the current path .

If you don't use the format above , It can also be used javac, But it should be noted that the package structure should be built by ourselves , The .class Put the files in this directory .

implement :java mypack.HelloWorld

Hand the bytecode file to java Virtual machine to explain the execution .

It should be noted that : Package name is required . Class name to explain the implementation .

java Operation process of

compile : Generate executable file (.class)

explain : The interpreter interprets the source file line by line , Cross platform but inefficient .

stay java in , Compile before explain , hold .java File compiled into .class Bytecode file :
Java Source code file (.java file ) Java compiler (javac) Java Bytecode file (.class file , Platform independent )
Java interpreter (java), implement java Bytecode
Java It's a cross platform language , It's not binary code that actually executes , It's bytecode .

Java Program execution is actually in JVM(Java Virtual
Machine,Java virtual machine ) On the implementation of the ,Java It's cross platform , and JVM It's not cross platform ,Java The reason why we can achieve cross platform , It's essentially because different systems are different JVM,JVM to java Provides the environment .

©2019-2020 Toolsou All rights reserved,
The 11th Blue Bridge Cup python The real topic of the University Group National Games JavaSwing To achieve a simple Lianliankan games 【Spring Source code analysis 】42-@Conditional Detailed explanation element-ui Step on pit record 2019PHP Interview questions ( Continuously updated )PHPJava Misunderstanding —— Method overloading is a manifestation of polymorphism ? First issue 500 100 million , Set up a new Department , What is Tencent going to do ? Google chrome The browser can't open the web page , But what if other browsers can open it ? Regression of dependent variable order categories (R language )【Golang Basic series 10 】Go language On conditional sentences if