Since  for  eggs  behalf  pregnant X

Since  for  eggs  behalf  pregnant X█ Micro Signal █: 138 • 0226 • 9370█ █ successful surrogacy package bag pack healthy sex surrogate █ ██ bag boy

I. Introduction

JEP330- start single-file code program (Launch Single-File Source-Code Programs), JDK11 is a very nice feature. This feature allows you to directly use the parser java run java code, java file will compile in memory and executed directly. The only constraint is that all of the relevant class must be defined in a java file in the East.

Second, examples

Case 1

Test.java create a file, the code is as follows:

public class Test {

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

The above code execution

jdk11 before:

javac Test.java
java Test

jdk11:

java Test.java

Conclusion: jdk11 by java xxx.java command, you can directly run the program source file, but does not produce .class files.

Case 2

Question: If there is more than one class in a java file, run by java xxx.java source code file, which will be a main method of execution?

Test1.java create a file, the code is as follows:

class Test2 { 
    public static void main(String[] args) { System.out.println("Test2"); } } public class Test { public static void main(String[] args) { System.out.println("Test"); } }

After running through java Test.java output "Test2".

Here we reversed Test Test2 two categories here:

public class Test {

    public static void main(String[] args) { System.out.println("Test"); } } class Test2 { public static void main(String[] args) { System.out.println("Test2"); } }

After running through java Test.java output "Test".

Conclusion: When a java file contains a plurality of classes, java xxx.java execute the main method of a class in the top row.

Case 3

Question: If a method java file class method calls another java class files, run by java xxx.java source file, run it through?

Create two java files Student.java, Teacher.java.

Student.java:

public class Student { 

    public static void main(String[] args) { Teacher teacher = new Teacher(); teacher.toString(); } }

Student.java:

public class Teacher {

    private String name; private String subject; public void setName(String name){ this.name = name; } public String getName(){ return name; } public void setSubject(String subject){ this.subject = subject; } public String getSubject(){ return subject; } }

Implementation of java Student.java error:

Student.java:4: 错误: 找不到符号
        Teacher teacher = new Teacher();
        ^
  符号:   类 Teacher
  位置: 类 Student
Student.java:4: 错误: 找不到符号
        Teacher teacher = new Teacher();
                              ^
  符号:   类 Teacher
  位置: 类 Student
2 个错误

The Student and Teacher even a class in a java file, re-run, run through.

Conclusion: java xxx.java launcher single Java source code files, related classes must be defined in the same java file.

CONCLUSIONS

Through the above three cases, I have come to the following conclusions:

  • jdk11 by java xxx.java command, you can directly run the program source file, but does not produce .class files.
  • When a file contains a plurality of java classes, java xxx.java execute the main method of a class in the top row.
  • When xxx.java java launcher single Java source code file, must be defined in the classes associated with a java file.

follow me

Guess you like

Origin www.cnblogs.com/DENG012/p/10948044.html