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,
Forbes China Auto rich list : He xiaopengdi 11 Li Xiangdi 14 Li Bindi 15 Change one's mind ! Tesla starts to deliver made in China to European market Model 3 The difference between memory overflow and memory leak , Causes and Solutions Character recognition technology of vehicle license plate based on Neural Network Vue Transfer parameters and receiving of page Jump SparkSQL Achieve partition overlay write 1190 Reverses the substring between each pair of parentheses leetcode Note 14 : The second biggest obstacle to motivating others in R & D management Chrome OS, For programmers and Windows What does it mean ? Internet Marketing JAVA Convert a string to a numeric type