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 .

3.java 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 . HelloWorld.java

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 HelloWorld.java, 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 .

Technology
©2019-2020 Toolsou All rights reserved,
【 Explain in detail 】 Interview must ask :SpringBoot Automatic configuration principle 【 Hyper detail 】Java Realization of student information management system 2020 The 11th National Blue Bridge Cup Python group JavaScript note ( five )---- Branch statement MYSQL database SQL Sentence practice experiment EXERCISES. 1 SIMPLE COMMANDSMySQL Basics Commonly used sentence ( Add / delete / modify query )C++ of string of compare usage vue limit input Only positive numbers can be entered C Language of a Gobang game implementation Programmer refused due to low salary offer,HR become shame , Netizens instantly blew up ..