4 ms·
That will not compile with javac, as it is not a method of a class.
That will not compile with javac, as it is not a method of a class.
Java has "unnamed classes" now which makes this work.
That code will it just needs to be in the proper context. No the same file will not compile, even if only because javac needs files to end with .java .