Notice that in earlier java 10 example, we gave class name HelloWorld to “java” with. In Java 11 example, we have given file name HelloWorld.java to “java”. When java file name is given to java command, it is called “source-file mode”.

As per openjdk,

In source-file mode, the effect is as if the source file is compiled into memory, and the first class found in the source file is executed